Backported the editor constrol changes for the new shortcut system from godot4.

This commit is contained in:
Relintai 2023-09-07 13:41:05 +02:00
parent 4637f73099
commit ccb6074ca9
15 changed files with 106 additions and 44 deletions

View File

@ -6074,6 +6074,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);
@ -6204,6 +6205,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);
@ -6217,12 +6219,8 @@ AnimationTrackEditor::AnimationTrackEditor() {
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()->add_shortcut(ED_SHORTCUT("animation_editor/add_reset_value", TTR("Add RESET Value(s)")));
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);

View File

@ -30,29 +30,27 @@
#include "editor_audio_buses.h"
#include "core/io/resource_saver.h"
#include "core/input/input.h"
#include "core/os/keyboard.h"
#include "editor_node.h"
#include "editor_scale.h"
#include "filesystem_dock.h"
#include "scene/resources/font.h"
#include "servers/audio_server.h"
#include "core/config/project_settings.h"
#include "core/object/class_db.h"
#include "core/variant/dictionary.h"
#include "core/error/error_list.h"
#include "core/error/error_macros.h"
#include "core/input/input.h"
#include "core/input/input_event.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/math/math_defs.h"
#include "core/math/math_funcs.h"
#include "core/math/rect2.h"
#include "core/input/input_event.h"
#include "core/object/class_db.h"
#include "core/object/undo_redo.h"
#include "core/os/keyboard.h"
#include "core/os/memory.h"
#include "core/string/string_name.h"
#include "core/object/undo_redo.h"
#include "core/variant/dictionary.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_settings.h"
#include "editor_node.h"
#include "editor_scale.h"
#include "filesystem_dock.h"
#include "scene/2d/canvas_item.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
@ -68,8 +66,10 @@
#include "scene/gui/tree.h"
#include "scene/main/node.h"
#include "scene/main/timer.h"
#include "scene/resources/font.h"
#include "scene/resources/style_box.h"
#include "servers/audio/audio_effect.h"
#include "servers/audio_server.h"
void EditorAudioBus::_update_visible_channels() {
int i = 0;
@ -567,12 +567,6 @@ 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_scancode() == 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()) {
Vector2 pos = Vector2(mb->get_position().x, mb->get_position().y);
@ -853,12 +847,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));
@ -975,9 +963,16 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
effect_options->set_item_metadata(effect_options->get_item_count() - 1, E->get());
}
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", this, "_bus_popup_pressed");

View File

@ -452,8 +452,8 @@ EditorLog::EditorLog() {
clear_button->set_flat(true);
clear_button->set_focus_mode(FOCUS_NONE);
clear_button->set_tooltip(TTR("Clear Output"));
//clear_button->set_shortcut(ED_SHORTCUT("editor/clear_output", TTR("Clear Output"), KEY_MASK_CTRL | KEY_MASK_SHIFT | KEY_K));
//clear_button->set_shortcut_context(this);
clear_button->set_shortcut(ED_SHORTCUT("editor/clear_output", TTR("Clear Output"), KEY_MASK_CTRL | KEY_MASK_SHIFT | KEY_K));
clear_button->set_shortcut_context(this);
clear_button->connect("pressed", this, "_clear_request");
hb_tools->add_child(clear_button);
@ -462,8 +462,8 @@ EditorLog::EditorLog() {
copy_button->set_flat(true);
copy_button->set_focus_mode(FOCUS_NONE);
copy_button->set_tooltip(TTR("Copy Selection"));
//copy_button->set_shortcut(ED_SHORTCUT("editor/copy_output", TTR("Copy Selection"), KEY_MASK_CTRL | KEY_K));
//copy_button->set_shortcut_context(this);
copy_button->set_shortcut(ED_SHORTCUT("editor/copy_output", TTR("Copy Selection"), KEY_MASK_CTRL | KEY_K));
copy_button->set_shortcut_context(this);
copy_button->connect("pressed", this, "_copy_request");
hb_tools->add_child(copy_button);
@ -489,8 +489,8 @@ EditorLog::EditorLog() {
show_search_button->set_toggle_mode(true);
show_search_button->set_pressed(false);
show_search_button->set_tooltip(TTR("Open Search/Filter Bar"));
//show_search_button->set_shortcut(ED_SHORTCUT("editor/open_search", TTR("Open Search/Filter Bar"), KEY_MASK_CTRL | KEY_F));
//show_search_button->set_shortcut_context(this);
show_search_button->set_shortcut(ED_SHORTCUT("editor/open_search", TTR("Open Search/Filter Bar"), KEY_MASK_CTRL | KEY_F));
show_search_button->set_shortcut_context(this);
show_search_button->connect("toggled", this, "_set_search_visible");
hb_tools2->add_child(show_search_button);

View File

@ -664,6 +664,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
property_tools_hb->add_child(search);
object_menu = memnew(MenuButton);
object_menu->set_shortcut_context(this);
object_menu->set_icon(get_theme_icon("Tools", "EditorIcons"));
property_tools_hb->add_child(object_menu);
object_menu->set_tooltip(TTR("Manage object properties."));

View File

@ -1305,11 +1305,10 @@ void AnimationPlayerEditor::_shortcut_input(const Ref<InputEvent> &p_ev) {
case KEY_A: {
if (!k->get_shift()) {
_play_bw_from_pressed();
accept_event();
} else {
_play_bw_pressed();
accept_event();
}
accept_event();
} break;
case KEY_S: {
_stop_pressed();
@ -1318,11 +1317,10 @@ void AnimationPlayerEditor::_shortcut_input(const Ref<InputEvent> &p_ev) {
case KEY_D: {
if (!k->get_shift()) {
_play_from_pressed();
accept_event();
} else {
_play_pressed();
accept_event();
}
accept_event();
} break;
}
}
@ -1666,6 +1664,7 @@ AnimationPlayerEditor::AnimationPlayerEditor(EditorNode *p_editor, AnimationPlay
delete_dialog->connect("confirmed", this, "_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"));

View File

@ -5452,12 +5452,14 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
zoom_hb->add_child(zoom_minus);
zoom_minus->connect("pressed", this, "_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(ToolButton);
zoom_hb->add_child(zoom_reset);
zoom_reset->connect("pressed", this, "_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
@ -5467,6 +5469,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
zoom_hb->add_child(zoom_plus);
zoom_plus->connect("pressed", this, "_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;
@ -5477,6 +5480,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
select_button->connect("pressed", this, "_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 selected node around pivot.") + "\n" + TTR("Alt+Drag: Move selected node.") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("Alt+Drag: Scale selected node.") + "\n" + TTR("V: Set selected node's pivot position.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked.") + "\n" + keycode_get_string(KEY_MASK_CMD) + TTR("RMB: Add node at position clicked."));
main_menu_hbox->add_child(memnew(VSeparator));
@ -5486,6 +5490,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
move_button->set_toggle_mode(true);
move_button->connect("pressed", this, "_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(ToolButton);
@ -5493,6 +5498,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
rotate_button->set_toggle_mode(true);
rotate_button->connect("pressed", this, "_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(ToolButton);
@ -5500,6 +5506,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
scale_button->set_toggle_mode(true);
scale_button->connect("pressed", this, "_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("Shift: Scale proportionally."));
main_menu_hbox->add_child(memnew(VSeparator));
@ -5521,6 +5528,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
pan_button->set_toggle_mode(true);
pan_button->connect("pressed", this, "_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(ToolButton);
@ -5528,6 +5536,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
ruler_button->set_toggle_mode(true);
ruler_button->connect("pressed", this, "_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"));
main_menu_hbox->add_child(memnew(VSeparator));
@ -5538,6 +5547,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
smart_snap_button->connect("toggled", this, "_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(ToolButton);
main_menu_hbox->add_child(grid_snap_button);
@ -5545,8 +5555,10 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
grid_snap_button->connect("toggled", this, "_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);
main_menu_hbox->add_child(snap_config_menu);
snap_config_menu->set_h_size_flags(SIZE_SHRINK_END);
snap_config_menu->set_tooltip(TTR("Snapping Options"));
@ -5606,6 +5618,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
main_menu_hbox->add_child(memnew(VSeparator));
skeleton_menu = memnew(MenuButton);
skeleton_menu->set_shortcut_context(this);
main_menu_hbox->add_child(skeleton_menu);
skeleton_menu->set_tooltip(TTR("Skeleton Options"));
skeleton_menu->set_switch_on_hover(true);
@ -5629,6 +5642,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
main_menu_hbox->add_child(memnew(VSeparator));
view_menu = memnew(MenuButton);
view_menu->set_shortcut_context(this);
view_menu->set_tooltip(TTR("View"));
main_menu_hbox->add_child(view_menu);
view_menu->get_popup()->connect("id_pressed", this, "_popup_callback");
@ -5658,6 +5672,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
preset_anchor_hbox->add_child(memnew(VSeparator));
presets_menu = memnew(MenuButton);
presets_menu->set_shortcut_context(this);
presets_menu->set_text(TTR("Layout"));
preset_anchor_hbox->add_child(presets_menu);
presets_menu->set_switch_on_hover(true);
@ -5688,6 +5703,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_loc_button->connect("pressed", this, "_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);
@ -5696,6 +5712,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_rot_button->connect("pressed", this, "_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);
@ -5703,23 +5720,27 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
key_scale_button->connect("pressed", this, "_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", this, "_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", this, "_popup_callback");

View File

@ -4443,9 +4443,10 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed
view_menu = memnew(MenuButton);
view_menu->set_flat(false);
vbox->add_child(view_menu);
view_menu->set_shortcut_context(this);
view_menu->set_h_size_flags(0);
view_menu->get_popup()->set_hide_on_checkable_item_selection(false);
vbox->add_child(view_menu);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/top_view"), VIEW_TOP);
view_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("spatial_editor/bottom_view"), VIEW_BOTTOM);
@ -7146,6 +7147,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_SELECT;
tool_button[TOOL_MODE_SELECT]->connect("pressed", this, "_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 selected node around pivot.") + "\n" + TTR("Alt+RMB: Show list of all nodes at position clicked, including locked."));
main_menu_hbox->add_child(memnew(VSeparator));
@ -7156,6 +7158,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_MOVE;
tool_button[TOOL_MODE_MOVE]->connect("pressed", this, "_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(ToolButton);
main_menu_hbox->add_child(tool_button[TOOL_MODE_ROTATE]);
@ -7164,6 +7167,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_ROTATE;
tool_button[TOOL_MODE_ROTATE]->connect("pressed", this, "_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(ToolButton);
main_menu_hbox->add_child(tool_button[TOOL_MODE_SCALE]);
@ -7172,6 +7176,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_SCALE;
tool_button[TOOL_MODE_SCALE]->connect("pressed", this, "_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);
main_menu_hbox->add_child(memnew(VSeparator));
@ -7220,6 +7225,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_LOCAL_COORDS;
tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", this, "_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(ToolButton);
main_menu_hbox->add_child(tool_option_button[TOOL_OPT_USE_SNAP]);
@ -7228,6 +7234,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
button_binds.write[0] = MENU_TOOL_USE_SNAP;
tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", this, "_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);
main_menu_hbox->add_child(memnew(VSeparator));
@ -7282,6 +7289,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
transform_menu = memnew(MenuButton);
transform_menu->set_tooltip(TTR("Transform"));
transform_menu->set_switch_on_hover(true);
transform_menu->set_shortcut_context(this);
main_menu_hbox->add_child(transform_menu);
p = transform_menu->get_popup();
@ -7296,6 +7304,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
view_menu = memnew(MenuButton);
view_menu->set_tooltip(TTR("View"));
view_menu->set_switch_on_hover(true);
view_menu->set_shortcut_context(this);
main_menu_hbox->add_child(view_menu);
// Get the view menu popup and have it stay open when a checkable item is selected

View File

@ -3583,6 +3583,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
quick_open = memnew(EditorQuickOpen);
add_child(quick_open);
quick_open->connect("quick_open", this, "_quick_open");
set_process_shortcut_input(true);
delete_dialog = memnew(ConfirmationDialog);

View File

@ -2581,13 +2581,15 @@ void EditorScriptEditor::_input(const Ref<InputEvent> &p_event) {
// Navigate the script history using additional mouse buttons present on some mice.
// This must be hardcoded as the editor shortcuts dialog doesn't allow assigning
// more than one shortcut per action.
if (mb.is_valid() && mb->is_pressed() && is_visible_in_tree() && !get_viewport()->gui_has_modal_stack()) {
if (mb.is_valid() && mb->is_pressed() && is_visible_in_tree() && is_focus_owner_in_shortcut_context() && !get_viewport()->gui_has_modal_stack()) {
if (mb->get_button_index() == BUTTON_XBUTTON1) {
_history_back();
accept_event();
}
if (mb->get_button_index() == BUTTON_XBUTTON2) {
_history_forward();
accept_event();
}
}
}
@ -2599,6 +2601,7 @@ void EditorScriptEditor::_shortcut_input(const Ref<InputEvent> &p_event) {
if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) {
return;
}
if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {
if (script_list->get_item_count() > 1) {
int next_tab = script_list->get_current() + 1;
@ -2608,6 +2611,7 @@ void EditorScriptEditor::_shortcut_input(const Ref<InputEvent> &p_event) {
}
accept_event();
}
if (ED_IS_SHORTCUT("script_editor/prev_script", p_event)) {
if (script_list->get_item_count() > 1) {
int next_tab = script_list->get_current() - 1;
@ -2617,10 +2621,12 @@ void EditorScriptEditor::_shortcut_input(const Ref<InputEvent> &p_event) {
}
accept_event();
}
if (ED_IS_SHORTCUT("script_editor/window_move_up", p_event)) {
_menu_option(WINDOW_MOVE_UP);
accept_event();
}
if (ED_IS_SHORTCUT("script_editor/window_move_down", p_event)) {
_menu_option(WINDOW_MOVE_DOWN);
accept_event();

View File

@ -1787,6 +1787,7 @@ EditorScriptTextEditor::EditorScriptTextEditor() {
edit_menu->set_text(TTR("Edit"));
edit_menu->set_switch_on_hover(true);
edit_menu->get_popup()->set_hide_on_window_lose_focus(true);
edit_menu->set_shortcut_context(this);
convert_case = memnew(PopupMenu);
convert_case->set_name("convert_case");
@ -1807,10 +1808,12 @@ EditorScriptTextEditor::EditorScriptTextEditor() {
search_menu->set_text(TTR("Search"));
search_menu->set_switch_on_hover(true);
search_menu->get_popup()->set_hide_on_window_lose_focus(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");

View File

@ -599,6 +599,7 @@ EditorTextEditor::EditorTextEditor() {
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);
@ -613,6 +614,7 @@ EditorTextEditor::EditorTextEditor() {
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);
@ -668,6 +670,7 @@ EditorTextEditor::EditorTextEditor() {
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);

View File

@ -642,6 +642,8 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
edit_menu = memnew(MenuButton);
edit_menu->set_text(TTR("Edit"));
edit_menu->set_switch_on_hover(true);
edit_menu->set_shortcut_context(this);
edit_menu->get_popup()->set_hide_on_window_lose_focus(true);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO);
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO);
@ -674,6 +676,7 @@ ShaderEditor::ShaderEditor(EditorNode *p_node) {
search_menu->get_popup()->connect("id_pressed", this, "_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", this, "_menu_option");

View File

@ -2036,6 +2036,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
// Tools.
paint_button = memnew(ToolButton);
paint_button->set_shortcut(ED_SHORTCUT("tile_map_editor/paint_tile", TTR("Paint Tile"), KEY_P));
paint_button->set_shortcut_context(this);
#ifdef OSX_ENABLED
paint_button->set_tooltip(TTR("Shift+LMB: Line Draw\nShift+Command+LMB: Rectangle Paint"));
#else
@ -2046,18 +2047,21 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
toolbar->add_child(paint_button);
bucket_fill_button = memnew(ToolButton);
bucket_fill_button->set_shortcut_context(this);
bucket_fill_button->set_shortcut(ED_SHORTCUT("tile_map_editor/bucket_fill", TTR("Bucket Fill"), KEY_B));
bucket_fill_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_BUCKET));
bucket_fill_button->set_toggle_mode(true);
toolbar->add_child(bucket_fill_button);
picker_button = memnew(ToolButton);
picker_button->set_shortcut_context(this);
picker_button->set_shortcut(ED_SHORTCUT("tile_map_editor/pick_tile", TTR("Pick Tile"), KEY_I));
picker_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_PICKING));
picker_button->set_toggle_mode(true);
toolbar->add_child(picker_button);
select_button = memnew(ToolButton);
select_button->set_shortcut_context(this);
select_button->set_shortcut(ED_SHORTCUT("tile_map_editor/select", TTR("Select"), KEY_M));
select_button->connect("pressed", this, "_button_tool_select", make_binds(TOOL_SELECTING));
select_button->set_toggle_mode(true);
@ -2083,9 +2087,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();
@ -2101,6 +2105,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
rotate_left_button->set_focus_mode(FOCUS_NONE);
rotate_left_button->connect("pressed", this, "_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(ToolButton);
@ -2108,6 +2113,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
rotate_right_button->set_focus_mode(FOCUS_NONE);
rotate_right_button->connect("pressed", this, "_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(ToolButton);
@ -2115,6 +2121,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
flip_horizontal_button->set_focus_mode(FOCUS_NONE);
flip_horizontal_button->connect("pressed", this, "_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(ToolButton);
@ -2122,6 +2129,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
flip_vertical_button->set_focus_mode(FOCUS_NONE);
flip_vertical_button->connect("pressed", this, "_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(ToolButton);
@ -2129,6 +2137,7 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
clear_transform_button->set_focus_mode(FOCUS_NONE);
clear_transform_button->connect("pressed", this, "_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);

View File

@ -443,11 +443,13 @@ TileSetEditor::TileSetEditor(EditorNode *p_editor) {
tool_hb->add_child(tools[SELECT_NEXT]);
tool_hb->move_child(tools[SELECT_NEXT], WORKSPACE_CREATE_SINGLE);
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", this, "_on_tool_clicked", varray(SELECT_NEXT));
tools[SELECT_NEXT]->set_tooltip(TTR("Select the next shape, subtile, or Tile."));
tools[SELECT_PREVIOUS] = memnew(ToolButton);
tool_hb->add_child(tools[SELECT_PREVIOUS]);
tool_hb->move_child(tools[SELECT_PREVIOUS], WORKSPACE_CREATE_SINGLE);
tools[SELECT_PREVIOUS]->set_shortcut_context(this);
tools[SELECT_PREVIOUS]->set_shortcut(ED_SHORTCUT("tileset_editor/previous_shape", TTR("Previous Coordinate"), KEY_PAGEUP));
tools[SELECT_PREVIOUS]->set_tooltip(TTR("Select the previous shape, subtile, or Tile."));
tools[SELECT_PREVIOUS]->connect("pressed", this, "_on_tool_clicked", varray(SELECT_PREVIOUS));
@ -495,6 +497,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);

View File

@ -2879,6 +2879,8 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("warp_mouse", "to_position"), &Control::warp_mouse);
ClassDB::bind_method(D_METHOD("is_focus_owner_in_shortcut_context"), &Control::is_focus_owner_in_shortcut_context);
ClassDB::bind_method(D_METHOD("set_shortcut_context", "node"), &Control::set_shortcut_context);
ClassDB::bind_method(D_METHOD("get_shortcut_context"), &Control::get_shortcut_context);