Skip to content

Commit f94af84

Browse files
committed
Replace QuickOpenDialog navigation keys with actions
1 parent 15ff450 commit f94af84

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

editor/gui/editor_quick_open_dialog.cpp

+23-26
Original file line numberDiff line numberDiff line change
@@ -538,35 +538,32 @@ void QuickOpenResultContainer::handle_search_box_input(const Ref<InputEvent> &p_
538538
}
539539

540540
Ref<InputEventKey> key_event = p_ie;
541-
if (key_event.is_valid() && key_event->is_pressed()) {
542-
bool move_selection = false;
543-
544-
switch (key_event->get_keycode()) {
545-
case Key::UP:
546-
case Key::DOWN:
547-
case Key::PAGEUP:
548-
case Key::PAGEDOWN: {
549-
move_selection = true;
550-
} break;
551-
case Key::LEFT:
552-
case Key::RIGHT: {
553-
if (content_display_mode == QuickOpenDisplayMode::GRID) {
554-
// Maybe strip off the shift modifier to allow non-selecting navigation by character?
555-
if (key_event->get_modifiers_mask() == 0) {
556-
move_selection = true;
557-
}
558-
}
559-
} break;
560-
default:
561-
break; // Let the event through so it will reach the search box.
562-
}
541+
if (key_event.is_null() || !key_event->is_pressed()) {
542+
return;
543+
}
563544

564-
if (move_selection) {
565-
_move_selection_index(key_event->get_keycode());
566-
queue_redraw();
567-
accept_event();
545+
Key move_selection = Key::NONE;
546+
if (p_ie->is_action("ui_up", true)) {
547+
move_selection = Key::UP;
548+
} else if (p_ie->is_action("ui_down", true)) {
549+
move_selection = Key::DOWN;
550+
} else if (p_ie->is_action("ui_page_up")) {
551+
move_selection = Key::PAGEUP;
552+
} else if (p_ie->is_action("ui_page_down")) {
553+
move_selection = Key::PAGEDOWN;
554+
} else if (content_display_mode == QuickOpenDisplayMode::GRID) {
555+
if (p_ie->is_action("ui_left", true)) {
556+
move_selection = Key::LEFT;
557+
} else if (p_ie->is_action("ui_right", true)) {
558+
move_selection = Key::RIGHT;
568559
}
569560
}
561+
562+
if (move_selection != Key::NONE) {
563+
_move_selection_index(key_event->get_keycode());
564+
queue_redraw();
565+
accept_event();
566+
}
570567
}
571568

572569
void QuickOpenResultContainer::_move_selection_index(Key p_key) {

0 commit comments

Comments
 (0)