Skip to content

Commit

Permalink
Replace QuickOpenDialog navigation keys with actions
Browse files Browse the repository at this point in the history
  • Loading branch information
KoBeWi committed Mar 2, 2025
1 parent 15ff450 commit a2d4579
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions editor/gui/editor_quick_open_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,35 +538,32 @@ void QuickOpenResultContainer::handle_search_box_input(const Ref<InputEvent> &p_
}

Ref<InputEventKey> key_event = p_ie;
if (key_event.is_valid() && key_event->is_pressed()) {
bool move_selection = false;

switch (key_event->get_keycode()) {
case Key::UP:
case Key::DOWN:
case Key::PAGEUP:
case Key::PAGEDOWN: {
move_selection = true;
} break;
case Key::LEFT:
case Key::RIGHT: {
if (content_display_mode == QuickOpenDisplayMode::GRID) {
// Maybe strip off the shift modifier to allow non-selecting navigation by character?
if (key_event->get_modifiers_mask() == 0) {
move_selection = true;
}
}
} break;
default:
break; // Let the event through so it will reach the search box.
}
if (key_event.is_null() || !key_event->is_pressed()) {
return;
}

if (move_selection) {
_move_selection_index(key_event->get_keycode());
queue_redraw();
accept_event();
Key move_selection = Key::NONE;
if (p_ie->is_action("ui_up", true)) {
move_selection = Key::UP;
} else if (p_ie->is_action("ui_down", true)) {
move_selection = Key::DOWN;
} else if (p_ie->is_action("ui_page_up")) {
move_selection = Key::PAGEUP;
} else if (p_ie->is_action("ui_page_down")) {
move_selection = Key::PAGEDOWN;
} else if (content_display_mode == QuickOpenDisplayMode::GRID) {
if (p_ie->is_action("ui_left", true)) {
move_selection = Key::LEFT;
} else if (p_ie->is_action("ui_right", true)) {
move_selection = Key::RIGHT;
}
}

if (move_selection) {
_move_selection_index(key_event->get_keycode());
queue_redraw();
accept_event();
}
}

void QuickOpenResultContainer::_move_selection_index(Key p_key) {
Expand Down

0 comments on commit a2d4579

Please sign in to comment.