diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-02-14 17:06:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 17:06:31 +0100 |
commit | eb2b04c6eb2b99f692ff0f17d784ec2ffc3c4061 (patch) | |
tree | 781aa664103dea044ad7265c04d31f383858bfcf | |
parent | 5a83705b199fd2848d17f5a3504f979fa8a235b6 (diff) | |
parent | bce2d2c297987295095b467867ae1cc41ee3ac8e (diff) |
Merge pull request #15379 from ianb96/delete_key_fix
Filesystem and Visual Script Members delete key fix
-rw-r--r-- | editor/filesystem_dock.cpp | 24 | ||||
-rw-r--r-- | editor/filesystem_dock.h | 2 | ||||
-rw-r--r-- | modules/visual_script/visual_script_editor.cpp | 44 | ||||
-rw-r--r-- | modules/visual_script/visual_script_editor.h | 1 |
4 files changed, 65 insertions, 6 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 9804d1d9a3..e26f4ba449 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -30,6 +30,7 @@ #include "filesystem_dock.h" +#include "core/os/keyboard.h" #include "editor_node.h" #include "editor_settings.h" #include "io/resource_loader.h" @@ -1641,6 +1642,23 @@ void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) { call_deferred("_update_import_dock"); } +void FileSystemDock::_files_gui_input(Ref<InputEvent> p_event) { + + if (get_viewport()->get_modal_stack_top()) + return; //ignore because of modal window + + Ref<InputEventKey> key = p_event; + if (key.is_valid() && key->is_pressed() && !key->is_echo()) { + if (ED_IS_SHORTCUT("filesystem_dock/duplicate", p_event)) { + _file_option(FILE_DUPLICATE); + } else if (ED_IS_SHORTCUT("filesystem_dock/copy_path", p_event)) { + _file_option(FILE_COPY_PATH); + } else if (ED_IS_SHORTCUT("filesystem_dock/delete", p_event)) { + _file_option(FILE_REMOVE); + } + } +} + void FileSystemDock::_file_selected() { import_dock_needs_update = true; @@ -1697,6 +1715,7 @@ void FileSystemDock::_update_import_dock() { void FileSystemDock::_bind_methods() { + ClassDB::bind_method(D_METHOD("_files_gui_input"), &FileSystemDock::_files_gui_input); ClassDB::bind_method(D_METHOD("_update_tree"), &FileSystemDock::_update_tree); ClassDB::bind_method(D_METHOD("_rescan"), &FileSystemDock::_rescan); ClassDB::bind_method(D_METHOD("_favorites_pressed"), &FileSystemDock::_favorites_pressed); @@ -1743,6 +1762,10 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { editor = p_editor; path = "res://"; + ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KEY_MASK_CMD | KEY_C); + ED_SHORTCUT("filesystem_dock/duplicate", TTR("Duplicate..."), KEY_MASK_CMD | KEY_D); + ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), KEY_DELETE); + HBoxContainer *toolbar_hbc = memnew(HBoxContainer); add_child(toolbar_hbc); @@ -1849,6 +1872,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { files->set_select_mode(ItemList::SELECT_MULTI); files->set_drag_forwarding(this); files->connect("item_rmb_selected", this, "_files_list_rmb_select"); + files->connect("gui_input", this, "_files_gui_input"); files->connect("item_selected", this, "_file_selected"); files->connect("multi_selected", this, "_file_multi_selected"); files->connect("rmb_clicked", this, "_rmb_pressed"); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 2e86b83efc..377316d1ba 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -159,6 +159,8 @@ private: bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths); void _update_tree(bool keep_collapse_state, bool p_uncollapse_root = false); + void _files_gui_input(Ref<InputEvent> p_event); + void _update_files(bool p_keep_selection); void _update_file_display_toggle_button(); void _change_file_display(); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index b116dfdcf7..69503e631c 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -1308,6 +1308,35 @@ void VisualScriptEditor::_input(const Ref<InputEvent> &p_event) { } } +void VisualScriptEditor::_members_gui_input(const Ref<InputEvent> &p_event) { + + Ref<InputEventKey> key = p_event; + if (key.is_valid() && key->is_pressed() && !key->is_echo()) { + if (members->has_focus()) { + TreeItem *ti = members->get_selected(); + if (ti) { + TreeItem *root = members->get_root(); + if (ti->get_parent() == root->get_children()) { + member_type = MEMBER_FUNCTION; + } + if (ti->get_parent() == root->get_children()->get_next()) { + member_type = MEMBER_VARIABLE; + } + if (ti->get_parent() == root->get_children()->get_next()->get_next()) { + member_type = MEMBER_SIGNAL; + } + member_name = ti->get_text(0); + } + if (ED_IS_SHORTCUT("visual_script_editor/delete_selected", p_event)) { + _member_option(MEMBER_REMOVE); + } + if (ED_IS_SHORTCUT("visual_script_editor/edit_member", p_event)) { + _member_option(MEMBER_EDIT); + } + } + } +} + Variant VisualScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { if (p_from == nodes) { @@ -3090,7 +3119,7 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) { member_type = MEMBER_FUNCTION; member_name = ti->get_text(0); - member_popup->add_icon_item(del_icon, TTR("Remove Function"), MEMBER_REMOVE); + member_popup->add_icon_shortcut(del_icon, ED_GET_SHORTCUT("visual_script_editor/delete_selected"), MEMBER_REMOVE); member_popup->popup(); return; } @@ -3099,9 +3128,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) { member_type = MEMBER_VARIABLE; member_name = ti->get_text(0); - member_popup->add_icon_item(edit_icon, TTR("Edit Variable"), MEMBER_EDIT); + member_popup->add_icon_shortcut(edit_icon, ED_GET_SHORTCUT("visual_script_editor/edit_member"), MEMBER_EDIT); member_popup->add_separator(); - member_popup->add_icon_item(del_icon, TTR("Remove Variable"), MEMBER_REMOVE); + member_popup->add_icon_shortcut(del_icon, ED_GET_SHORTCUT("visual_script_editor/delete_selected"), MEMBER_REMOVE); member_popup->popup(); return; } @@ -3110,9 +3139,9 @@ void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) { member_type = MEMBER_SIGNAL; member_name = ti->get_text(0); - member_popup->add_icon_item(edit_icon, TTR("Edit Signal"), MEMBER_EDIT); + member_popup->add_icon_shortcut(edit_icon, ED_GET_SHORTCUT("visual_script_editor/edit_member"), MEMBER_EDIT); member_popup->add_separator(); - member_popup->add_icon_item(del_icon, TTR("Remove Signal"), MEMBER_REMOVE); + member_popup->add_icon_shortcut(del_icon, ED_GET_SHORTCUT("visual_script_editor/delete_selected"), MEMBER_REMOVE); member_popup->popup(); return; } @@ -3243,6 +3272,7 @@ void VisualScriptEditor::_bind_methods() { ClassDB::bind_method("drop_data_fw", &VisualScriptEditor::drop_data_fw); ClassDB::bind_method("_input", &VisualScriptEditor::_input); + ClassDB::bind_method("_members_gui_input", &VisualScriptEditor::_members_gui_input); ClassDB::bind_method("_on_nodes_delete", &VisualScriptEditor::_on_nodes_delete); ClassDB::bind_method("_on_nodes_duplicate", &VisualScriptEditor::_on_nodes_duplicate); @@ -3305,6 +3335,7 @@ VisualScriptEditor::VisualScriptEditor() { members->connect("button_pressed", this, "_member_button"); members->connect("item_edited", this, "_member_edited"); members->connect("cell_selected", this, "_member_selected", varray(), CONNECT_DEFERRED); + members->connect("gui_input", this, "_members_gui_input"); members->set_allow_reselect(true); members->set_hide_folding(true); members->set_drag_forwarding(this); @@ -3478,12 +3509,13 @@ static void register_editor_callback() { ScriptEditor::register_create_script_editor_function(create_editor); - ED_SHORTCUT("visual_script_editor/delete_selected", TTR("Delete Selected")); + ED_SHORTCUT("visual_script_editor/delete_selected", TTR("Delete Selected"), KEY_DELETE); ED_SHORTCUT("visual_script_editor/toggle_breakpoint", TTR("Toggle Breakpoint"), KEY_F9); ED_SHORTCUT("visual_script_editor/find_node_type", TTR("Find Node Type"), KEY_MASK_CMD + KEY_F); ED_SHORTCUT("visual_script_editor/copy_nodes", TTR("Copy Nodes"), KEY_MASK_CMD + KEY_C); ED_SHORTCUT("visual_script_editor/cut_nodes", TTR("Cut Nodes"), KEY_MASK_CMD + KEY_X); ED_SHORTCUT("visual_script_editor/paste_nodes", TTR("Paste Nodes"), KEY_MASK_CMD + KEY_V); + ED_SHORTCUT("visual_script_editor/edit_member", TTR("Edit Member"), KEY_MASK_CMD + KEY_E); } void VisualScriptEditor::register_editor() { diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index 4d789e6ef7..80bbf142d9 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -211,6 +211,7 @@ class VisualScriptEditor : public ScriptEditorBase { String revert_on_drag; void _input(const Ref<InputEvent> &p_event); + void _members_gui_input(const Ref<InputEvent> &p_event); void _on_nodes_delete(); void _on_nodes_duplicate(); |