You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Implement new shortcuts system.
unhandled_key_input changed to unhandled_button_input. Controls can set a 'shortcut_context' which they can then use to determine if their shortcuts should be triggered or not, based on if the viewport's focused GUI control is a child of their 'shortcut context'.
This commit is contained in:
@@ -3903,8 +3903,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);
|
||||
@@ -6217,6 +6218,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));
|
||||
@@ -6228,6 +6230,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]);
|
||||
@@ -6236,6 +6239,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]);
|
||||
@@ -6244,6 +6248,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));
|
||||
|
||||
@@ -6292,6 +6297,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]);
|
||||
@@ -6300,6 +6306,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));
|
||||
|
||||
@@ -6337,6 +6344,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();
|
||||
@@ -6351,6 +6359,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();
|
||||
|
||||
Reference in New Issue
Block a user