From 72557b6fbc5f76ba52d52fad4c18be7cd3174ee1 Mon Sep 17 00:00:00 2001 From: Franklin Sobrinho Date: Sun, 17 Jan 2016 10:25:15 -0300 Subject: Improved "Qucik Open" dialog navigation --- tools/editor/quick_open.cpp | 45 ++++++++++++++++++++++++++++++++++----------- 1 file 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 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); } -- cgit v1.2.3