Fix recursive Tree expand/collapse shortcuts not working
This also moves them to use Shift instead of Alt, as was already done for mouse interactions. Shortcuts in Tree were also made non-exact matches so they still work if modifiers are held. This is important for up/down shortcuts, especially once support for selecting with Shift + up/down is implemented.
This commit is contained in:
parent
9050ee1542
commit
6de0eca6c1
2 changed files with 13 additions and 23 deletions
|
@ -353,7 +353,7 @@
|
|||
This controls the drop sections, i.e. the decision and drawing of possible drop locations based on the mouse position.
|
||||
</member>
|
||||
<member name="enable_recursive_folding" type="bool" setter="set_enable_recursive_folding" getter="is_recursive_folding_enabled" default="true">
|
||||
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.
|
||||
</member>
|
||||
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" overrides="Control" enum="Control.FocusMode" default="2" />
|
||||
<member name="hide_folding" type="bool" setter="set_hide_folding" getter="is_folding_hidden" default="false">
|
||||
|
|
|
@ -3394,7 +3394,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
|
|||
Ref<InputEventKey> 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<InputEvent> &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<InputEvent> &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<InputEvent> &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<InputEvent> &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<InputEvent> &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;
|
||||
|
|
Loading…
Reference in a new issue