1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +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:
Eric M
2020-09-17 11:40:00 +10:00
parent fc806409f4
commit efe5c250d5
26 changed files with 154 additions and 54 deletions

View File

@@ -407,6 +407,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);
@@ -414,6 +415,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));
@@ -460,6 +462,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);