diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index bf5a504aba1..88cda5ae10f 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -353,7 +353,7 @@ This controls the drop sections, i.e. the decision and drawing of possible drop locations based on the mouse position. - If [code]true[/code], recursive folding is enabled for this [Tree]. Holding down Shift while clicking the fold arrow collapses or uncollapses the [TreeItem] and all its descendants. + If [code]true[/code], recursive folding is enabled for this [Tree]. Holding down [kbd]Shift[/kbd] while clicking the fold arrow or using [code]ui_right[/code]/[code]ui_left[/code] shortcuts collapses or uncollapses the [TreeItem] and all its descendants. diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 73a49fd427a..bf456cd0485 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3394,7 +3394,7 @@ void Tree::gui_input(const Ref &p_event) { Ref k = p_event; bool is_command = k.is_valid() && k->is_command_or_control_pressed(); - if (p_event->is_action("ui_right", true) && p_event->is_pressed()) { + if (p_event->is_action("ui_right") && p_event->is_pressed()) { if (!cursor_can_exit_tree) { accept_event(); } @@ -3402,17 +3402,12 @@ void Tree::gui_input(const Ref &p_event) { if (!selected_item || select_mode == SELECT_ROW || selected_col > (columns.size() - 1)) { return; } - if (k.is_valid() && k->is_alt_pressed()) { - selected_item->set_collapsed(false); - TreeItem *next = selected_item->get_first_child(); - while (next && next != selected_item->next) { - next->set_collapsed(false); - next = next->get_next_visible(); - } + if (k.is_valid() && k->is_shift_pressed()) { + selected_item->set_collapsed_recursive(false); } else { _go_right(); } - } else if (p_event->is_action("ui_left", true) && p_event->is_pressed()) { + } else if (p_event->is_action("ui_left") && p_event->is_pressed()) { if (!cursor_can_exit_tree) { accept_event(); } @@ -3421,32 +3416,27 @@ void Tree::gui_input(const Ref &p_event) { return; } - if (k.is_valid() && k->is_alt_pressed()) { - selected_item->set_collapsed(true); - TreeItem *next = selected_item->get_first_child(); - while (next && next != selected_item->next) { - next->set_collapsed(true); - next = next->get_next_visible(); - } + if (k.is_valid() && k->is_shift_pressed()) { + selected_item->set_collapsed_recursive(true); } else { _go_left(); } - } else if (p_event->is_action("ui_up", true) && p_event->is_pressed() && !is_command) { + } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !is_command) { if (!cursor_can_exit_tree) { accept_event(); } _go_up(); - } else if (p_event->is_action("ui_down", true) && p_event->is_pressed() && !is_command) { + } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !is_command) { if (!cursor_can_exit_tree) { accept_event(); } _go_down(); - } else if (p_event->is_action("ui_page_down", true) && p_event->is_pressed()) { + } else if (p_event->is_action("ui_page_down") && p_event->is_pressed()) { if (!cursor_can_exit_tree) { accept_event(); } @@ -3484,7 +3474,7 @@ void Tree::gui_input(const Ref &p_event) { } ensure_cursor_is_visible(); - } else if (p_event->is_action("ui_page_up", true) && p_event->is_pressed()) { + } else if (p_event->is_action("ui_page_up") && p_event->is_pressed()) { if (!cursor_can_exit_tree) { accept_event(); } @@ -3521,7 +3511,7 @@ void Tree::gui_input(const Ref &p_event) { prev->select(selected_col); } ensure_cursor_is_visible(); - } else if (p_event->is_action("ui_accept", true) && p_event->is_pressed()) { + } else if (p_event->is_action("ui_accept") && p_event->is_pressed()) { if (selected_item) { //bring up editor if possible if (!edit_selected()) { @@ -3530,7 +3520,7 @@ void Tree::gui_input(const Ref &p_event) { } } accept_event(); - } else if (p_event->is_action("ui_select", true) && p_event->is_pressed()) { + } else if (p_event->is_action("ui_select") && p_event->is_pressed()) { if (select_mode == SELECT_MULTI) { if (!selected_item) { return;