diff options
author | Franklin Sobrinho <franklin_gs@hotmail.com> | 2016-01-17 10:25:15 -0300 |
---|---|---|
committer | Franklin Sobrinho <franklin_gs@hotmail.com> | 2016-01-17 10:49:52 -0300 |
commit | 72557b6fbc5f76ba52d52fad4c18be7cd3174ee1 (patch) | |
tree | 7f6c22ae73c489379dd4b593162c172e8c1ba3cf | |
parent | 72fcb8a35beab251d01864bc67da3e3a8e75aed6 (diff) |
Improved "Qucik Open" dialog navigation
-rw-r--r-- | tools/editor/quick_open.cpp | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp index 22f4a40c83..828275340b 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -78,14 +78,33 @@ void EditorQuickOpen::_text_changed(const String& p_newtext) { void EditorQuickOpen::_sbox_input(const InputEvent& p_ie) { - if (p_ie.type==InputEvent::KEY && ( - p_ie.key.scancode == KEY_UP || - p_ie.key.scancode == KEY_DOWN || - p_ie.key.scancode == KEY_PAGEUP || - p_ie.key.scancode == KEY_PAGEDOWN ) ) { - - search_options->call("_input_event",p_ie); - search_box->accept_event(); + if (p_ie.type==InputEvent::KEY) { + + switch(p_ie.key.scancode) { + case KEY_UP: + case KEY_DOWN: + case KEY_PAGEUP: + case KEY_PAGEDOWN: { + + search_options->call("_input_event", p_ie); + search_box->accept_event(); + + TreeItem *root = search_options->get_root(); + if (!root->get_children()) + break; + + TreeItem *current = search_options->get_selected(); + + TreeItem *item = search_options->get_next_selected(root); + while (item) { + item->deselect(0); + item = search_options->get_next_selected(item); + } + + current->select(0); + + } break; + } } } @@ -125,9 +144,6 @@ void EditorQuickOpen::_parse_fs(EditorFileSystemDirectory *efsd) { ti->set_text(0,file); Ref<Texture> icon = get_icon( (has_icon(efsd->get_file_type(i),ei)?efsd->get_file_type(i):ot),ei); ti->set_icon(0,icon); - if (root->get_children()==ti) - ti->select(0); - } } @@ -148,6 +164,13 @@ void EditorQuickOpen::_update_search() { TreeItem *root = search_options->create_item(); _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); + if (root->get_children()) { + TreeItem *ti = root->get_children(); + + ti->select(0); + ti->set_as_cursor(0); + } + get_ok()->set_disabled(root->get_children()==NULL); } |