Skip to content

Commit

Permalink
Merge pull request #96232 from AThousandShips/tree_navigate_row
Browse files Browse the repository at this point in the history
[Tree] Improve navigation with row select mode
  • Loading branch information
akien-mga committed Sep 8, 2024
2 parents b4dc87d + 5c21c0d commit 325c1cf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions scene/gui/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3466,29 +3466,37 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
accept_event();
}

if (!selected_item || select_mode == SELECT_ROW || selected_col > (columns.size() - 1)) {
if (!selected_item || selected_col > (columns.size() - 1)) {
return;
}

if (k.is_valid() && k->is_shift_pressed()) {
selected_item->set_collapsed_recursive(false);
} else {
} else if (select_mode != SELECT_ROW) {
_go_right();
} else if (selected_item->get_first_child() != nullptr && selected_item->is_collapsed()) {
selected_item->set_collapsed(false);
} else {
_go_down();
}
} else if (p_event->is_action("ui_left") && p_event->is_pressed()) {
if (!cursor_can_exit_tree) {
accept_event();
}

if (!selected_item || select_mode == SELECT_ROW || selected_col < 0) {
if (!selected_item || selected_col < 0) {
return;
}

if (k.is_valid() && k->is_shift_pressed()) {
selected_item->set_collapsed_recursive(true);
} else {
} else if (select_mode != SELECT_ROW) {
_go_left();
} else if (selected_item->get_first_child() != nullptr && !selected_item->is_collapsed()) {
selected_item->set_collapsed(true);
} else {
_go_up();
}

} else if (p_event->is_action("ui_up") && p_event->is_pressed() && !is_command) {
if (!cursor_can_exit_tree) {
accept_event();
Expand Down

0 comments on commit 325c1cf

Please sign in to comment.