diff options
Diffstat (limited to 'editor')
22 files changed, 125 insertions, 70 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index d4d4c7d809..b1ffb1dc52 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -5574,6 +5574,7 @@ AnimationTrackEditor::AnimationTrackEditor() { undo_redo = EditorNode::get_singleton()->get_undo_redo(); main_panel = memnew(PanelContainer); + main_panel->set_focus_mode(FOCUS_ALL); // allow panel to have focus so that shortcuts work as expected. add_child(main_panel); main_panel->set_v_size_flags(SIZE_EXPAND_FILL); HBoxContainer *timeline_scroll = memnew(HBoxContainer); @@ -5707,6 +5708,7 @@ AnimationTrackEditor::AnimationTrackEditor() { timeline->set_zoom(zoom); edit = memnew(MenuButton); + edit->set_shortcut_context(this); edit->set_text(TTR("Edit")); edit->set_flat(false); edit->set_disabled(true); @@ -5719,12 +5721,8 @@ AnimationTrackEditor::AnimationTrackEditor() { edit->get_popup()->add_separator(); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/duplicate_selection", TTR("Duplicate Selection"), KEY_MASK_CMD | KEY_D), EDIT_DUPLICATE_SELECTION); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/duplicate_selection_transposed", TTR("Duplicate Transposed"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_D), EDIT_DUPLICATE_TRANSPOSED); - edit->get_popup()->set_item_shortcut_disabled(edit->get_popup()->get_item_index(EDIT_DUPLICATE_SELECTION), true); - edit->get_popup()->set_item_shortcut_disabled(edit->get_popup()->get_item_index(EDIT_DUPLICATE_TRANSPOSED), true); edit->get_popup()->add_separator(); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/delete_selection", TTR("Delete Selection"), KEY_DELETE), EDIT_DELETE_SELECTION); - edit->get_popup()->set_item_shortcut_disabled(edit->get_popup()->get_item_index(EDIT_DELETE_SELECTION), true); - //this shortcut will be checked from the track itself. so no need to enable it here (will conflict with scenetree dock) edit->get_popup()->add_separator(); edit->get_popup()->add_shortcut(ED_SHORTCUT("animation_editor/goto_next_step", TTR("Go to Next Step"), KEY_MASK_CMD | KEY_RIGHT), EDIT_GOTO_NEXT_STEP); diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 6dc0fffd92..0888fecc67 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -531,21 +531,15 @@ void EditorAudioBus::_effect_add(int p_which) { } void EditorAudioBus::_gui_input(const Ref<InputEvent> &p_event) { - Ref<InputEventKey> k = p_event; - if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && !k->is_echo()) { - accept_event(); - emit_signal("delete_request"); - } - Ref<InputEventMouseButton> mb = p_event; - if (mb.is_valid() && mb->get_button_index() == 2 && mb->is_pressed()) { + if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { Vector2 pos = Vector2(mb->get_position().x, mb->get_position().y); bus_popup->set_position(get_global_position() + pos); bus_popup->popup(); } } -void EditorAudioBus::_unhandled_key_input(Ref<InputEvent> p_event) { +void EditorAudioBus::_effects_gui_input(Ref<InputEvent> p_event) { Ref<InputEventKey> k = p_event; if (k.is_valid() && k->is_pressed() && !k->is_echo() && k->get_keycode() == KEY_DELETE) { TreeItem *current_effect = effects->get_selected(); @@ -749,7 +743,6 @@ void EditorAudioBus::_bind_methods() { ClassDB::bind_method("update_bus", &EditorAudioBus::update_bus); ClassDB::bind_method("update_send", &EditorAudioBus::update_send); ClassDB::bind_method("_gui_input", &EditorAudioBus::_gui_input); - ClassDB::bind_method("_unhandled_key_input", &EditorAudioBus::_unhandled_key_input); ClassDB::bind_method("get_drag_data_fw", &EditorAudioBus::get_drag_data_fw); ClassDB::bind_method("can_drop_data_fw", &EditorAudioBus::can_drop_data_fw); ClassDB::bind_method("drop_data_fw", &EditorAudioBus::drop_data_fw); @@ -773,7 +766,6 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { add_child(vb); set_v_size_flags(SIZE_EXPAND_FILL); - set_process_unhandled_key_input(true); track_name = memnew(LineEdit); track_name->connect("text_entered", callable_mp(this, &EditorAudioBus::_name_changed)); @@ -805,12 +797,6 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { hbc->add_child(bypass); hbc->add_spacer(); - bus_options = memnew(MenuButton); - bus_options->set_h_size_flags(SIZE_SHRINK_END); - bus_options->set_anchor(MARGIN_RIGHT, 0.0); - bus_options->set_tooltip(TTR("Bus options")); - hbc->add_child(bus_options); - Ref<StyleBoxEmpty> sbempty = memnew(StyleBoxEmpty); for (int i = 0; i < hbc->get_child_count(); i++) { Control *child = Object::cast_to<Control>(hbc->get_child(i)); @@ -906,6 +892,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { effects->set_allow_rmb_select(true); effects->set_focus_mode(FOCUS_CLICK); effects->set_allow_reselect(true); + effects->connect("gui_input", callable_mp(this, &EditorAudioBus::_effects_gui_input)); send = memnew(OptionButton); send->set_clip_text(true); @@ -932,9 +919,16 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { effect_options->set_item_icon(effect_options->get_item_count() - 1, icon); } + bus_options = memnew(MenuButton); + bus_options->set_shortcut_context(this); + bus_options->set_h_size_flags(SIZE_SHRINK_END); + bus_options->set_anchor(MARGIN_RIGHT, 0.0); + bus_options->set_tooltip(TTR("Bus options")); + hbc->add_child(bus_options); + bus_popup = bus_options->get_popup(); - bus_popup->add_item(TTR("Duplicate")); - bus_popup->add_item(TTR("Delete")); + bus_popup->add_shortcut(ED_SHORTCUT("audio_bus_editor/duplicate_selected_bus", TTR("Duplicate Bus"), KEY_MASK_CMD | KEY_D)); + bus_popup->add_shortcut(ED_SHORTCUT("audio_bus_editor/delete_selected_bus", TTR("Delete Bus"), KEY_DELETE)); bus_popup->set_item_disabled(1, is_master); bus_popup->add_item(TTR("Reset Volume")); bus_popup->connect("index_pressed", callable_mp(this, &EditorAudioBus::_bus_popup_pressed)); diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h index b6cf1183b5..01221ad6ef 100644 --- a/editor/editor_audio_buses.h +++ b/editor/editor_audio_buses.h @@ -91,7 +91,7 @@ class EditorAudioBus : public PanelContainer { mutable bool hovering_drop; void _gui_input(const Ref<InputEvent> &p_event); - void _unhandled_key_input(Ref<InputEvent> p_event); + void _effects_gui_input(Ref<InputEvent> p_event); void _bus_popup_pressed(int p_option); void _name_changed(const String &p_new_name); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 72bd2b57eb..2c49782fd2 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -56,19 +56,6 @@ void EditorHelp::_init_colors() { class_desc->add_theme_constant_override("line_separation", Math::round(5 * EDSCALE)); } -void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) { - if (!is_visible_in_tree()) { - return; - } - - Ref<InputEventKey> k = p_ev; - - if (k.is_valid() && k->get_control() && k->get_keycode() == KEY_F) { - search->grab_focus(); - search->select_all(); - } -} - void EditorHelp::_search(bool p_search_previous) { if (p_search_previous) { find_bar->search_prev(); @@ -1599,7 +1586,6 @@ void EditorHelp::set_scroll(int p_scroll) { void EditorHelp::_bind_methods() { ClassDB::bind_method("_class_list_select", &EditorHelp::_class_list_select); ClassDB::bind_method("_request_help", &EditorHelp::_request_help); - ClassDB::bind_method("_unhandled_key_input", &EditorHelp::_unhandled_key_input); ClassDB::bind_method("_search", &EditorHelp::_search); ClassDB::bind_method("_help_callback", &EditorHelp::_help_callback); diff --git a/editor/editor_help.h b/editor/editor_help.h index b69b6d7401..cdb674cffd 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -158,8 +158,6 @@ class EditorHelp : public VBoxContainer { void _request_help(const String &p_string); void _search(bool p_search_previous = false); - void _unhandled_key_input(const Ref<InputEvent> &p_ev); - String _fix_constant(const String &p_constant) const; protected: diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 9c713f748e..371cabfe3d 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -162,12 +162,14 @@ EditorLog::EditorLog() { hb->add_child(copybutton); copybutton->set_text(TTR("Copy")); copybutton->set_shortcut(ED_SHORTCUT("editor/copy_output", TTR("Copy Selection"), KEY_MASK_CMD | KEY_C)); + copybutton->set_shortcut_context(this); copybutton->connect("pressed", callable_mp(this, &EditorLog::_copy_request)); clearbutton = memnew(Button); hb->add_child(clearbutton); clearbutton->set_text(TTR("Clear")); clearbutton->set_shortcut(ED_SHORTCUT("editor/clear_output", TTR("Clear Output"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_K)); + clearbutton->set_shortcut_context(this); clearbutton->connect("pressed", callable_mp(this, &EditorLog::_clear_request)); log = memnew(RichTextLabel); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 75f89fbfb5..e0ba50fe4f 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -569,6 +569,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { node_info_hb->add_child(editor_path); object_menu = memnew(MenuButton); + object_menu->set_shortcut_context(this); object_menu->set_icon(get_theme_icon("Tools", "EditorIcons")); node_info_hb->add_child(object_menu); object_menu->set_tooltip(TTR("Object properties.")); diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 6b30aa325c..17cfb5f5f3 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1212,9 +1212,11 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { } else { _play_bw_pressed(); } + accept_event(); } break; case KEY_S: { _stop_pressed(); + accept_event(); } break; case KEY_D: { if (!k->get_shift()) { @@ -1222,6 +1224,7 @@ void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { } else { _play_pressed(); } + accept_event(); } break; } } @@ -1547,6 +1550,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay delete_dialog->connect("confirmed", callable_mp(this, &AnimationPlayerEditor::_animation_remove_confirmed)); tool_anim = memnew(MenuButton); + tool_anim->set_shortcut_context(this); tool_anim->set_flat(false); tool_anim->set_tooltip(TTR("Animation Tools")); tool_anim->set_text(TTR("Animation")); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 5742becf3a..9ecf5193a2 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -580,7 +580,7 @@ void EditorAssetLibrary::_notification(int p_what) { } } -void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) { +void EditorAssetLibrary::_unhandled_key_input(const Ref<InputEvent> &p_event) { const Ref<InputEventKey> key = p_event; if (key.is_valid() && key->is_pressed()) { @@ -1281,7 +1281,7 @@ void EditorAssetLibrary::disable_community_support() { } void EditorAssetLibrary::_bind_methods() { - ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input); + ClassDB::bind_method("_unhandled_key_input", &EditorAssetLibrary::_unhandled_key_input); ADD_SIGNAL(MethodInfo("install_asset", PropertyInfo(Variant::STRING, "zip_path"), PropertyInfo(Variant::STRING, "name"))); } @@ -1454,7 +1454,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { description = nullptr; set_process(true); - set_process_unhandled_input(true); + set_process_unhandled_key_input(true); // Global shortcuts since there is no main element to be focused. downloads_scroll = memnew(ScrollContainer); downloads_scroll->set_enable_h_scroll(true); diff --git a/editor/plugins/asset_library_editor_plugin.h b/editor/plugins/asset_library_editor_plugin.h index f7ad53f87b..9761dbba1e 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -298,7 +298,7 @@ class EditorAssetLibrary : public PanelContainer { protected: static void _bind_methods(); void _notification(int p_what); - void _unhandled_input(const Ref<InputEvent> &p_event); + void _unhandled_key_input(const Ref<InputEvent> &p_event); public: void disable_community_support(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 47a30ad5d7..5d9c46cdcb 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -478,22 +478,24 @@ void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { return; } - if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) { - viewport->update(); - } - - if (k->is_pressed() && !k->get_control() && !k->is_echo()) { - if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) { - // Multiply the grid size - grid_step_multiplier = MIN(grid_step_multiplier + 1, 12); + if (k.is_valid()) { + if (k->get_keycode() == KEY_CONTROL || k->get_keycode() == KEY_ALT || k->get_keycode() == KEY_SHIFT) { viewport->update(); - } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) { - // Divide the grid size - Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1); - if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) { - grid_step_multiplier--; + } + + if (k->is_pressed() && !k->get_control() && !k->is_echo()) { + if ((grid_snap_active || show_grid) && multiply_grid_step_shortcut.is_valid() && multiply_grid_step_shortcut->is_shortcut(p_ev)) { + // Multiply the grid size + grid_step_multiplier = MIN(grid_step_multiplier + 1, 12); + viewport->update(); + } else if ((grid_snap_active || show_grid) && divide_grid_step_shortcut.is_valid() && divide_grid_step_shortcut->is_shortcut(p_ev)) { + // Divide the grid size + Point2 new_grid_step = grid_step * Math::pow(2.0, grid_step_multiplier - 1); + if (new_grid_step.x >= 1.0 && new_grid_step.y >= 1.0) { + grid_step_multiplier--; + } + viewport->update(); } - viewport->update(); } } } @@ -5752,6 +5754,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { zoom_hb->add_child(zoom_minus); zoom_minus->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_zoom_minus)); zoom_minus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_minus", TTR("Zoom Out"), KEY_MASK_CMD | KEY_MINUS)); + zoom_minus->set_shortcut_context(this); zoom_minus->set_focus_mode(FOCUS_NONE); zoom_reset = memnew(Button); @@ -5762,6 +5765,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { zoom_reset->add_theme_color_override("font_color", Color(1, 1, 1)); zoom_reset->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_zoom_reset)); zoom_reset->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_reset", TTR("Zoom Reset"), KEY_MASK_CMD | KEY_0)); + zoom_reset->set_shortcut_context(this); zoom_reset->set_focus_mode(FOCUS_NONE); zoom_reset->set_text_align(Button::TextAlign::ALIGN_CENTER); // Prevent the button's size from changing when the text size changes @@ -5772,6 +5776,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { zoom_hb->add_child(zoom_plus); zoom_plus->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_zoom_plus)); zoom_plus->set_shortcut(ED_SHORTCUT("canvas_item_editor/zoom_plus", TTR("Zoom In"), KEY_MASK_CMD | KEY_EQUAL)); // Usually direct access key for PLUS + zoom_plus->set_shortcut_context(this); zoom_plus->set_focus_mode(FOCUS_NONE); updating_scroll = false; @@ -5783,6 +5788,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { select_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_SELECT)); select_button->set_pressed(true); select_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/select_mode", TTR("Select Mode"), KEY_Q)); + select_button->set_shortcut_context(this); select_button->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate") + "\n" + TTR("Alt+Drag: Move") + "\n" + TTR("Press 'v' to Change Pivot, 'Shift+v' to Drag Pivot (while moving).") + "\n" + TTR("Alt+RMB: Depth list selection")); hb->add_child(memnew(VSeparator)); @@ -5793,6 +5799,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { move_button->set_toggle_mode(true); move_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_MOVE)); move_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/move_mode", TTR("Move Mode"), KEY_W)); + move_button->set_shortcut_context(this); move_button->set_tooltip(TTR("Move Mode")); rotate_button = memnew(Button); @@ -5801,6 +5808,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { rotate_button->set_toggle_mode(true); rotate_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_ROTATE)); rotate_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/rotate_mode", TTR("Rotate Mode"), KEY_E)); + rotate_button->set_shortcut_context(this); rotate_button->set_tooltip(TTR("Rotate Mode")); scale_button = memnew(Button); @@ -5809,6 +5817,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { scale_button->set_toggle_mode(true); scale_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_SCALE)); scale_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/scale_mode", TTR("Scale Mode"), KEY_S)); + scale_button->set_shortcut_context(this); scale_button->set_tooltip(TTR("Scale Mode")); hb->add_child(memnew(VSeparator)); @@ -5833,6 +5842,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { pan_button->set_toggle_mode(true); pan_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_PAN)); pan_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/pan_mode", TTR("Pan Mode"), KEY_G)); + pan_button->set_shortcut_context(this); pan_button->set_tooltip(TTR("Pan Mode")); ruler_button = memnew(Button); @@ -5841,6 +5851,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { ruler_button->set_toggle_mode(true); ruler_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_button_tool_select), make_binds(TOOL_RULER)); ruler_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/ruler_mode", TTR("Ruler Mode"), KEY_R)); + ruler_button->set_shortcut_context(this); ruler_button->set_tooltip(TTR("Ruler Mode")); hb->add_child(memnew(VSeparator)); @@ -5852,6 +5863,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { smart_snap_button->connect("toggled", callable_mp(this, &CanvasItemEditor::_button_toggle_smart_snap)); smart_snap_button->set_tooltip(TTR("Toggle smart snapping.")); smart_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_smart_snap", TTR("Use Smart Snap"), KEY_MASK_SHIFT | KEY_S)); + smart_snap_button->set_shortcut_context(this); grid_snap_button = memnew(Button); grid_snap_button->set_flat(true); @@ -5860,8 +5872,10 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { grid_snap_button->connect("toggled", callable_mp(this, &CanvasItemEditor::_button_toggle_grid_snap)); grid_snap_button->set_tooltip(TTR("Toggle grid snapping.")); grid_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_grid_snap", TTR("Use Grid Snap"), KEY_MASK_SHIFT | KEY_G)); + grid_snap_button->set_shortcut_context(this); snap_config_menu = memnew(MenuButton); + snap_config_menu->set_shortcut_context(this); hb->add_child(snap_config_menu); snap_config_menu->set_h_size_flags(SIZE_SHRINK_END); snap_config_menu->set_tooltip(TTR("Snapping Options")); @@ -5921,6 +5935,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb->add_child(memnew(VSeparator)); skeleton_menu = memnew(MenuButton); + skeleton_menu->set_shortcut_context(this); hb->add_child(skeleton_menu); skeleton_menu->set_tooltip(TTR("Skeleton Options")); skeleton_menu->set_switch_on_hover(true); @@ -5949,6 +5964,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { hb->add_child(memnew(VSeparator)); view_menu = memnew(MenuButton); + view_menu->set_shortcut_context(this); view_menu->set_text(TTR("View")); hb->add_child(view_menu); view_menu->get_popup()->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_popup_callback)); @@ -5973,6 +5989,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { p->add_check_shortcut(ED_SHORTCUT("canvas_item_editor/preview_canvas_scale", TTR("Preview Canvas Scale"), KEY_MASK_SHIFT | KEY_MASK_CMD | KEY_P), PREVIEW_CANVAS_SCALE); presets_menu = memnew(MenuButton); + presets_menu->set_shortcut_context(this); presets_menu->set_text(TTR("Layout")); hb->add_child(presets_menu); presets_menu->hide(); @@ -6006,6 +6023,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_loc_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_POS)); key_loc_button->set_tooltip(TTR("Translation mask for inserting keys.")); animation_hb->add_child(key_loc_button); + key_rot_button = memnew(Button); key_rot_button->set_toggle_mode(true); key_rot_button->set_flat(true); @@ -6014,6 +6032,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_rot_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_ROT)); key_rot_button->set_tooltip(TTR("Rotation mask for inserting keys.")); animation_hb->add_child(key_rot_button); + key_scale_button = memnew(Button); key_scale_button->set_toggle_mode(true); key_scale_button->set_flat(true); @@ -6021,23 +6040,27 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { key_scale_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_SCALE)); key_scale_button->set_tooltip(TTR("Scale mask for inserting keys.")); animation_hb->add_child(key_scale_button); + key_insert_button = memnew(Button); key_insert_button->set_flat(true); key_insert_button->set_focus_mode(FOCUS_NONE); key_insert_button->connect("pressed", callable_mp(this, &CanvasItemEditor::_popup_callback), varray(ANIM_INSERT_KEY)); key_insert_button->set_tooltip(TTR("Insert keys (based on mask).")); key_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_insert_key", TTR("Insert Key"), KEY_INSERT)); + key_insert_button->set_shortcut_context(this); animation_hb->add_child(key_insert_button); + key_auto_insert_button = memnew(Button); key_auto_insert_button->set_flat(true); key_auto_insert_button->set_toggle_mode(true); key_auto_insert_button->set_focus_mode(FOCUS_NONE); - //key_auto_insert_button->connect("pressed", this, "_popup_callback", varray(ANIM_INSERT_KEY)); key_auto_insert_button->set_tooltip(TTR("Auto insert keys when objects are translated, rotated or scaled (based on mask).\nKeys are only added to existing tracks, no new tracks will be created.\nKeys must be inserted manually for the first time.")); key_auto_insert_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/anim_auto_insert_key", TTR("Auto Insert Key"))); + key_auto_insert_button->set_shortcut_context(this); animation_hb->add_child(key_auto_insert_button); animation_menu = memnew(MenuButton); + animation_menu->set_shortcut_context(this); animation_menu->set_tooltip(TTR("Animation Key and Pose Options")); animation_hb->add_child(animation_menu); animation_menu->get_popup()->connect("id_pressed", callable_mp(this, &CanvasItemEditor::_popup_callback)); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index fd5c4df3f3..ccf868b3d5 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -3906,8 +3906,9 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, Edito view_menu = memnew(MenuButton); view_menu->set_flat(false); - vbox->add_child(view_menu); view_menu->set_h_size_flags(0); + view_menu->set_shortcut_context(this); + vbox->add_child(view_menu); display_submenu = memnew(PopupMenu); view_menu->get_popup()->add_child(display_submenu); @@ -6220,6 +6221,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { button_binds.write[0] = MENU_TOOL_SELECT; tool_button[TOOL_MODE_SELECT]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_SELECT]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_select", TTR("Select Mode"), KEY_Q)); + tool_button[TOOL_MODE_SELECT]->set_shortcut_context(this); tool_button[TOOL_MODE_SELECT]->set_tooltip(keycode_get_string(KEY_MASK_CMD) + TTR("Drag: Rotate\nAlt+Drag: Move\nAlt+RMB: Depth list selection")); hbc_menu->add_child(memnew(VSeparator)); @@ -6231,6 +6233,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { button_binds.write[0] = MENU_TOOL_MOVE; tool_button[TOOL_MODE_MOVE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_MOVE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_move", TTR("Move Mode"), KEY_W)); + tool_button[TOOL_MODE_MOVE]->set_shortcut_context(this); tool_button[TOOL_MODE_ROTATE] = memnew(Button); hbc_menu->add_child(tool_button[TOOL_MODE_ROTATE]); @@ -6239,6 +6242,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { button_binds.write[0] = MENU_TOOL_ROTATE; tool_button[TOOL_MODE_ROTATE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_ROTATE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_rotate", TTR("Rotate Mode"), KEY_E)); + tool_button[TOOL_MODE_ROTATE]->set_shortcut_context(this); tool_button[TOOL_MODE_SCALE] = memnew(Button); hbc_menu->add_child(tool_button[TOOL_MODE_SCALE]); @@ -6247,6 +6251,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { button_binds.write[0] = MENU_TOOL_SCALE; tool_button[TOOL_MODE_SCALE]->connect("pressed", callable_mp(this, &Node3DEditor::_menu_item_pressed), button_binds); tool_button[TOOL_MODE_SCALE]->set_shortcut(ED_SHORTCUT("spatial_editor/tool_scale", TTR("Scale Mode"), KEY_R)); + tool_button[TOOL_MODE_SCALE]->set_shortcut_context(this); hbc_menu->add_child(memnew(VSeparator)); @@ -6295,6 +6300,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { button_binds.write[0] = MENU_TOOL_LOCAL_COORDS; tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Use Local Space"), KEY_T)); + tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut_context(this); tool_option_button[TOOL_OPT_USE_SNAP] = memnew(Button); hbc_menu->add_child(tool_option_button[TOOL_OPT_USE_SNAP]); @@ -6303,6 +6309,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { button_binds.write[0] = MENU_TOOL_USE_SNAP; tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled), button_binds); tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut(ED_SHORTCUT("spatial_editor/snap", TTR("Use Snap"), KEY_Y)); + tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut_context(this); hbc_menu->add_child(memnew(VSeparator)); @@ -6340,6 +6347,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { transform_menu = memnew(MenuButton); transform_menu->set_text(TTR("Transform")); transform_menu->set_switch_on_hover(true); + transform_menu->set_shortcut_context(this); hbc_menu->add_child(transform_menu); p = transform_menu->get_popup(); @@ -6354,6 +6362,7 @@ Node3DEditor::Node3DEditor(EditorNode *p_editor) { view_menu = memnew(MenuButton); view_menu->set_text(TTR("View")); view_menu->set_switch_on_hover(true); + view_menu->set_shortcut_context(this); hbc_menu->add_child(view_menu); p = view_menu->get_popup(); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index e7b6959ac6..6ee8193291 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -2644,7 +2644,7 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co } } -void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) { +void ScriptEditor::_unhandled_key_input(const Ref<InputEvent> &p_event) { if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) { return; } @@ -3172,7 +3172,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_update_script_connections", &ScriptEditor::_update_script_connections); ClassDB::bind_method("_help_class_open", &ScriptEditor::_help_class_open); ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts); - ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input); + ClassDB::bind_method("_unhandled_key_input", &ScriptEditor::_unhandled_key_input); ClassDB::bind_method("_update_members_overview", &ScriptEditor::_update_members_overview); ClassDB::bind_method("_update_recent_scripts", &ScriptEditor::_update_recent_scripts); @@ -3299,12 +3299,13 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { ED_SHORTCUT("script_editor/window_move_down", TTR("Move Down"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_DOWN); ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_PERIOD); // these should be KEY_GREATER and KEY_LESS but those don't work ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_COMMA); - set_process_unhandled_input(true); + set_process_unhandled_key_input(true); file_menu = memnew(MenuButton); - menu_hb->add_child(file_menu); file_menu->set_text(TTR("File")); file_menu->set_switch_on_hover(true); + file_menu->set_shortcut_context(this); + menu_hb->add_child(file_menu); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new", TTR("New Script...")), FILE_NEW); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/new_textfile", TTR("New Text File...")), FILE_NEW_TEXTFILE); @@ -3359,10 +3360,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option)); script_search_menu = memnew(MenuButton); - menu_hb->add_child(script_search_menu); script_search_menu->set_text(TTR("Search")); script_search_menu->set_switch_on_hover(true); + script_search_menu->set_shortcut_context(this); script_search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ScriptEditor::_menu_option)); + menu_hb->add_child(script_search_menu); MenuButton *debug_menu = memnew(MenuButton); menu_hb->add_child(debug_menu); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 32f47239ef..f1453c3d20 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -402,7 +402,7 @@ class ScriptEditor : public PanelContainer { bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); - void _unhandled_input(const Ref<InputEvent> &p_event); + void _unhandled_key_input(const Ref<InputEvent> &p_event); void _script_list_gui_input(const Ref<InputEvent> &ev); void _make_script_list_context_menu(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index fbd3612c72..e854ed4fb3 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1849,6 +1849,7 @@ ScriptTextEditor::ScriptTextEditor() { edit_menu = memnew(MenuButton); edit_menu->set_text(TTR("Edit")); edit_menu->set_switch_on_hover(true); + edit_menu->set_shortcut_context(this); convert_case = memnew(PopupMenu); convert_case->set_name("convert_case"); @@ -1868,10 +1869,12 @@ ScriptTextEditor::ScriptTextEditor() { search_menu = memnew(MenuButton); search_menu->set_text(TTR("Search")); search_menu->set_switch_on_hover(true); + search_menu->set_shortcut_context(this); goto_menu = memnew(MenuButton); goto_menu->set_text(TTR("Go To")); goto_menu->set_switch_on_hover(true); + goto_menu->set_shortcut_context(this); bookmarks_menu = memnew(PopupMenu); bookmarks_menu->set_name("Bookmarks"); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 0063bec9de..5b0e1ce5b5 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -581,6 +581,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { HBoxContainer *hbc = memnew(HBoxContainer); edit_menu = memnew(MenuButton); + edit_menu->set_shortcut_context(this); edit_menu->set_text(TTR("Edit")); edit_menu->set_switch_on_hover(true); @@ -605,6 +606,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { edit_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option)); search_menu = memnew(MenuButton); + search_menu->set_shortcut_context(this); search_menu->set_text(TTR("Search")); search_menu->set_switch_on_hover(true); @@ -615,6 +617,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) { search_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option)); MenuButton *goto_menu = memnew(MenuButton); + goto_menu->set_shortcut_context(this); goto_menu->set_text(TTR("Go To")); goto_menu->set_switch_on_hover(true); goto_menu->get_popup()->connect("id_pressed", callable_mp(this, &ShaderEditor::_menu_option)); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 8935b698b6..9894d0e1b0 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -563,6 +563,7 @@ TextEditor::TextEditor() { edit_hb = memnew(HBoxContainer); search_menu = memnew(MenuButton); + search_menu->set_shortcut_context(this); edit_hb->add_child(search_menu); search_menu->set_text(TTR("Search")); search_menu->set_switch_on_hover(true); @@ -577,6 +578,7 @@ TextEditor::TextEditor() { search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace_in_files"), REPLACE_IN_FILES); edit_menu = memnew(MenuButton); + edit_menu->set_shortcut_context(this); edit_hb->add_child(edit_menu); edit_menu->set_text(TTR("Edit")); edit_menu->set_switch_on_hover(true); @@ -631,6 +633,7 @@ TextEditor::TextEditor() { set_syntax_highlighter(plain_highlighter); MenuButton *goto_menu = memnew(MenuButton); + goto_menu->set_shortcut_context(this); edit_hb->add_child(goto_menu); goto_menu->set_text(TTR("Go To")); goto_menu->set_switch_on_hover(true); diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index ceec3f1830..6c0efcb254 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -2109,6 +2109,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { paint_button = memnew(Button); paint_button->set_flat(true); paint_button->set_shortcut(ED_SHORTCUT("tile_map_editor/paint_tile", TTR("Paint Tile"), KEY_P)); + paint_button->set_shortcut_context(this); paint_button->set_tooltip(TTR("RMB: Erase")); paint_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_NONE)); paint_button->set_toggle_mode(true); @@ -2117,6 +2118,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { line_button = memnew(Button); line_button->set_flat(true); line_button->set_shortcut(ED_SHORTCUT("tile_map_editor/line_fill", TTR("Line Fill"), KEY_L)); + line_button->set_shortcut_context(this); line_button->set_tooltip(TTR("RMB: Erase")); line_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_LINE_PAINT)); line_button->set_toggle_mode(true); @@ -2125,6 +2127,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { rectangle_button = memnew(Button); rectangle_button->set_flat(true); rectangle_button->set_shortcut(ED_SHORTCUT("tile_map_editor/rectangle_fill", TTR("Rectangle Fill"), KEY_O)); + rectangle_button->set_shortcut_context(this); rectangle_button->set_tooltip(TTR("Shift+LMB: Keep 1:1 proporsions\nRMB: Erase")); rectangle_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_RECTANGLE_PAINT)); rectangle_button->set_toggle_mode(true); @@ -2133,6 +2136,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { bucket_fill_button = memnew(Button); bucket_fill_button->set_flat(true); bucket_fill_button->set_shortcut(ED_SHORTCUT("tile_map_editor/bucket_fill", TTR("Bucket Fill"), KEY_B)); + bucket_fill_button->set_shortcut_context(this); bucket_fill_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_BUCKET)); bucket_fill_button->set_toggle_mode(true); toolbar->add_child(bucket_fill_button); @@ -2140,6 +2144,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { picker_button = memnew(Button); picker_button->set_flat(true); picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_I)); + picker_button->set_shortcut_context(this); picker_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_PICKING)); picker_button->set_toggle_mode(true); toolbar->add_child(picker_button); @@ -2147,6 +2152,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { select_button = memnew(Button); select_button->set_flat(true); select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_M)); + select_button->set_shortcut_context(this); select_button->connect("pressed", callable_mp(this, &TileMapEditor::_button_tool_select), make_binds(TOOL_SELECTING)); select_button->set_toggle_mode(true); toolbar->add_child(select_button); @@ -2172,9 +2178,9 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { // Menu. options = memnew(MenuButton); + options->set_shortcut_context(this); options->set_text("TileMap"); options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("TileMap", "EditorIcons")); - options->set_process_unhandled_key_input(false); toolbar_right->add_child(options); PopupMenu *p = options->get_popup(); @@ -2191,6 +2197,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { rotate_left_button->set_focus_mode(FOCUS_NONE); rotate_left_button->connect("pressed", callable_mp(this, &TileMapEditor::_rotate), varray(-1)); rotate_left_button->set_shortcut(ED_SHORTCUT("tile_map_editor/rotate_left", TTR("Rotate Left"), KEY_A)); + rotate_left_button->set_shortcut_context(this); tool_hb->add_child(rotate_left_button); rotate_right_button = memnew(Button); @@ -2199,6 +2206,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { rotate_right_button->set_focus_mode(FOCUS_NONE); rotate_right_button->connect("pressed", callable_mp(this, &TileMapEditor::_rotate), varray(1)); rotate_right_button->set_shortcut(ED_SHORTCUT("tile_map_editor/rotate_right", TTR("Rotate Right"), KEY_S)); + rotate_right_button->set_shortcut_context(this); tool_hb->add_child(rotate_right_button); flip_horizontal_button = memnew(Button); @@ -2207,6 +2215,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { flip_horizontal_button->set_focus_mode(FOCUS_NONE); flip_horizontal_button->connect("pressed", callable_mp(this, &TileMapEditor::_flip_horizontal)); flip_horizontal_button->set_shortcut(ED_SHORTCUT("tile_map_editor/flip_horizontal", TTR("Flip Horizontally"), KEY_X)); + flip_horizontal_button->set_shortcut_context(this); tool_hb->add_child(flip_horizontal_button); flip_vertical_button = memnew(Button); @@ -2215,6 +2224,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { flip_vertical_button->set_focus_mode(FOCUS_NONE); flip_vertical_button->connect("pressed", callable_mp(this, &TileMapEditor::_flip_vertical)); flip_vertical_button->set_shortcut(ED_SHORTCUT("tile_map_editor/flip_vertical", TTR("Flip Vertically"), KEY_Z)); + flip_vertical_button->set_shortcut_context(this); tool_hb->add_child(flip_vertical_button); clear_transform_button = memnew(Button); @@ -2223,6 +2233,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) { clear_transform_button->set_focus_mode(FOCUS_NONE); clear_transform_button->connect("pressed", callable_mp(this, &TileMapEditor::_clear_transform)); clear_transform_button->set_shortcut(ED_SHORTCUT("tile_map_editor/clear_transform", TTR("Clear Transform"), KEY_W)); + clear_transform_button->set_shortcut_context(this); tool_hb->add_child(clear_transform_button); clear_transform_button->set_disabled(true); diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 9dc01d83d7..6d2fd65dd6 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -414,6 +414,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { tool_hb->move_child(tools[SELECT_NEXT], WORKSPACE_CREATE_SINGLE); tools[SELECT_NEXT]->set_flat(true); tools[SELECT_NEXT]->set_shortcut(ED_SHORTCUT("tileset_editor/next_shape", TTR("Next Coordinate"), KEY_PAGEDOWN)); + tools[SELECT_NEXT]->set_shortcut_context(this); tools[SELECT_NEXT]->connect("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(SELECT_NEXT)); tools[SELECT_NEXT]->set_tooltip(TTR("Select the next shape, subtile, or Tile.")); tools[SELECT_PREVIOUS] = memnew(Button); @@ -421,6 +422,7 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { tool_hb->move_child(tools[SELECT_PREVIOUS], WORKSPACE_CREATE_SINGLE); tools[SELECT_PREVIOUS]->set_flat(true); tools[SELECT_PREVIOUS]->set_shortcut(ED_SHORTCUT("tileset_editor/previous_shape", TTR("Previous Coordinate"), KEY_PAGEUP)); + tools[SELECT_PREVIOUS]->set_shortcut_context(this); tools[SELECT_PREVIOUS]->set_tooltip(TTR("Select the previous shape, subtile, or Tile.")); tools[SELECT_PREVIOUS]->connect("pressed", callable_mp(this, &TileSetEditor::_on_tool_clicked), varray(SELECT_PREVIOUS)); @@ -467,6 +469,16 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) { tool_editmode[EDITMODE_ICON]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_icon", TTR("Icon Mode"), KEY_7)); tool_editmode[EDITMODE_Z_INDEX]->set_shortcut(ED_SHORTCUT("tileset_editor/editmode_z_index", TTR("Z Index Mode"), KEY_8)); + tool_editmode[EDITMODE_REGION]->set_shortcut_context(this); + tool_editmode[EDITMODE_REGION]->set_shortcut_context(this); + tool_editmode[EDITMODE_COLLISION]->set_shortcut_context(this); + tool_editmode[EDITMODE_OCCLUSION]->set_shortcut_context(this); + tool_editmode[EDITMODE_NAVIGATION]->set_shortcut_context(this); + tool_editmode[EDITMODE_BITMASK]->set_shortcut_context(this); + tool_editmode[EDITMODE_PRIORITY]->set_shortcut_context(this); + tool_editmode[EDITMODE_ICON]->set_shortcut_context(this); + tool_editmode[EDITMODE_Z_INDEX]->set_shortcut_context(this); + main_vb->add_child(tool_hb); separator_editmode = memnew(HSeparator); main_vb->add_child(separator_editmode); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index bbe6a73f8f..47b1135133 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1854,7 +1854,7 @@ void ProjectManager::_notification(int p_what) { } } break; case NOTIFICATION_VISIBILITY_CHANGED: { - set_process_unhandled_input(is_visible_in_tree()); + set_process_unhandled_key_input(is_visible_in_tree()); } break; case NOTIFICATION_WM_CLOSE_REQUEST: { _dim_window(); @@ -1893,7 +1893,7 @@ void ProjectManager::_update_project_buttons() { erase_missing_btn->set_disabled(!_project_list->is_any_project_missing()); } -void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { +void ProjectManager::_unhandled_key_input(const Ref<InputEvent> &p_ev) { Ref<InputEventKey> k = p_ev; if (k.is_valid()) { @@ -2357,7 +2357,7 @@ void ProjectManager::_on_search_term_changed(const String &p_term) { void ProjectManager::_bind_methods() { ClassDB::bind_method("_exit_dialog", &ProjectManager::_exit_dialog); - ClassDB::bind_method("_unhandled_input", &ProjectManager::_unhandled_input); + ClassDB::bind_method("_unhandled_key_input", &ProjectManager::_unhandled_key_input); ClassDB::bind_method("_update_project_buttons", &ProjectManager::_update_project_buttons); } diff --git a/editor/project_manager.h b/editor/project_manager.h index 0a8a86eb4f..0eb063e196 100644 --- a/editor/project_manager.h +++ b/editor/project_manager.h @@ -112,7 +112,7 @@ class ProjectManager : public Control { void _install_project(const String &p_zip_path, const String &p_title); void _dim_window(); - void _unhandled_input(const Ref<InputEvent> &p_ev); + void _unhandled_key_input(const Ref<InputEvent> &p_ev); void _files_dropped(PackedStringArray p_files, int p_screen); void _on_order_option_changed(int p_idx); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index d946a08fbf..fafb90e864 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -114,7 +114,12 @@ void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) { _tool_selected(TOOL_COPY_NODE_PATH); } else if (ED_IS_SHORTCUT("scene_tree/delete", p_event)) { _tool_selected(TOOL_ERASE); + } else { + return; } + + // Tool selection was successful, accept the event to stop propagation. + accept_event(); } void SceneTreeDock::instance(const String &p_file) { @@ -2957,6 +2962,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel quick_open = memnew(EditorQuickOpen); add_child(quick_open); quick_open->connect("quick_open", callable_mp(this, &SceneTreeDock::_quick_open)); + set_process_unhandled_key_input(true); delete_dialog = memnew(ConfirmationDialog); |