Improved "Qucik Open" dialog navigation

This commit is contained in:
Franklin Sobrinho 2016-01-17 10:25:15 -03:00
parent 72fcb8a35b
commit 72557b6fbc

View file

@ -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 ) ) {
if (p_ie.type==InputEvent::KEY) {
search_options->call("_input_event",p_ie);
search_box->accept_event();
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);
}