diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index cb910eb8467..5a765d56f8e 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -1102,6 +1102,10 @@ If [code]true[/code], enable two finger pan and scale gestures on touchscreen devices. [b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices. + + If [code]true[/code], enables the TouchActionsPanel to provide easy access to keyboard shortcuts on touchscreen devices. + [b]Note:[/b] Only available in the Android editor. + If [code]true[/code], increases the scrollbar touch area to improve usability on touchscreen devices. [b]Note:[/b] Defaults to [code]true[/code] on touchscreen devices. diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 6e2789f559a..3563c9d81f7 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -7931,7 +7931,10 @@ EditorNode::EditorNode() { #ifdef ANDROID_ENABLED // Add TouchActionsPanel node. - add_child(memnew(TouchActionsPanel)); + bool is_enabled = EDITOR_GET("interface/touchscreen/enable_touch_actions_panel"); + if (is_enabled) { + add_child(memnew(TouchActionsPanel)); + } #endif // Bottom panels. diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 5985ff342e3..0a293144001 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -584,6 +584,10 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/touchscreen/scale_gizmo_handles", has_touchscreen_ui ? 3 : 1, "1,5,1") set_restart_if_changed("interface/touchscreen/scale_gizmo_handles", true); + // Only available in the Android editor. + EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_touch_actions_panel", true, "") + set_restart_if_changed("interface/touchscreen/enable_touch_actions_panel", true); + // Disable some touchscreen settings by default for the XR Editor. bool is_native_touchscreen = has_touchscreen_ui && !OS::get_singleton()->has_feature("xr_editor"); EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/touchscreen/enable_long_press_as_right_click", is_native_touchscreen, "") diff --git a/editor/gui/touch_actions_panel.cpp b/editor/gui/touch_actions_panel.cpp index 29a0143899e..ba61bb3e16d 100644 --- a/editor/gui/touch_actions_panel.cpp +++ b/editor/gui/touch_actions_panel.cpp @@ -41,6 +41,10 @@ void TouchActionsPanel::_notification(int p_what) { switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + DisplayServer::get_singleton()->set_hardware_keyboard_connection_change_callback(callable_mp(this, &TouchActionsPanel::_hardware_keyboard_connected)); + _hardware_keyboard_connected(DisplayServer::get_singleton()->has_hardware_keyboard()); + } break; case NOTIFICATION_THEME_CHANGED: { drag_handle->set_texture(get_editor_theme_icon(SNAME("DragHandle"))); layout_toggle_button->set_button_icon(get_editor_theme_icon(SNAME("Orientation"))); @@ -53,6 +57,10 @@ void TouchActionsPanel::_notification(int p_what) { } } +void TouchActionsPanel::_hardware_keyboard_connected(bool p_connected) { + set_visible(!p_connected); +} + void TouchActionsPanel::_simulate_editor_shortcut(const String &p_shortcut_name) { Ref shortcut = ED_GET_SHORTCUT(p_shortcut_name); diff --git a/editor/gui/touch_actions_panel.h b/editor/gui/touch_actions_panel.h index 516d37d2820..ddb637b1dc3 100644 --- a/editor/gui/touch_actions_panel.h +++ b/editor/gui/touch_actions_panel.h @@ -63,6 +63,8 @@ private: void _lock_panel_toggled(bool p_pressed); Button *_add_new_action_button(const String &p_shortcut, Key p_keycode = Key::NONE); + void _hardware_keyboard_connected(bool p_connected); + public: TouchActionsPanel(); };