diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-02-10 11:34:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 11:34:47 +0100 |
commit | 50e940129a4a80e68e22464ae45410f0a69ccd98 (patch) | |
tree | a97757c7d83d40dd4e82d1d0aa235d761671131d | |
parent | 4ee8c5ad1f0bc58d1c76831f4f4052e0631e179c (diff) | |
parent | 0899fce7a587c135ed315be32c1a8f05261acf05 (diff) |
Merge pull request #33815 from Calinou/assetlib-focus-search-shortcut
Make Ctrl+F focus the editor asset library's search field
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 19 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 2428bf82d4..d88a716122 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -31,6 +31,8 @@ #include "asset_library_editor_plugin.h" #include "core/io/json.h" +#include "core/os/input.h" +#include "core/os/keyboard.h" #include "core/version.h" #include "editor/editor_node.h" #include "editor/editor_scale.h" @@ -620,6 +622,21 @@ void EditorAssetLibrary::_notification(int p_what) { } } +void EditorAssetLibrary::_unhandled_input(const Ref<InputEvent> &p_event) { + + const Ref<InputEventKey> key = p_event; + + if (key.is_valid() && key->is_pressed()) { + + if (key->get_scancode_with_modifiers() == (KEY_MASK_CMD | KEY_F) && is_visible_in_tree()) { + + filter->grab_focus(); + filter->select_all(); + accept_event(); + } + } +} + void EditorAssetLibrary::_install_asset() { ERR_FAIL_COND(!description); @@ -1320,6 +1337,7 @@ void EditorAssetLibrary::disable_community_support() { void EditorAssetLibrary::_bind_methods() { + ClassDB::bind_method("_unhandled_input", &EditorAssetLibrary::_unhandled_input); ClassDB::bind_method("_http_request_completed", &EditorAssetLibrary::_http_request_completed); ClassDB::bind_method("_select_asset", &EditorAssetLibrary::_select_asset); ClassDB::bind_method("_select_author", &EditorAssetLibrary::_select_author); @@ -1502,6 +1520,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { description = NULL; set_process(true); + set_process_unhandled_input(true); 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 aa3c735810..8852125b8b 100644 --- a/editor/plugins/asset_library_editor_plugin.h +++ b/editor/plugins/asset_library_editor_plugin.h @@ -300,6 +300,7 @@ class EditorAssetLibrary : public PanelContainer { protected: static void _bind_methods(); void _notification(int p_what); + void _unhandled_input(const Ref<InputEvent> &p_event); public: void disable_community_support(); |