summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-09-25 23:16:06 +0200
committerGitHub <noreply@github.com>2017-09-25 23:16:06 +0200
commit938681724f80ef6ae5c1e0bc64b479bae7fdda5c (patch)
treeff4f641f21026b23a1101f1c34b2ce97000ef1fd
parent1aabf4c1668bd989db6667a2dcc76d5699d84833 (diff)
parent35c5422dc2e3451abfc3f3debadcb69dabb77c23 (diff)
Merge pull request #11541 from Paulb23/tree_arrow_goto_parent
Goto to parent on left arrow in tree with single column [ci skip]
-rw-r--r--scene/gui/tree.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 8d6eb0f8e2..822136820e 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2135,8 +2135,15 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
if (selected_item->get_children() != NULL && !selected_item->is_collapsed()) {
selected_item->set_collapsed(true);
} else {
- selected_col = columns.size() - 1;
- dobreak = false; // fall through to key_up
+ if (columns.size() == 1) { // goto parent with one column
+ TreeItem *parent = selected_item->get_parent();
+ if (selected_item != get_root() && parent && parent->is_selectable(selected_col) && !(hide_root && parent == get_root())) {
+ select_single_item(parent, get_root(), selected_col);
+ }
+ } else {
+ selected_col = columns.size() - 1;
+ dobreak = false; // fall through to key_up
+ }
}
} else {
if (select_mode == SELECT_MULTI) {
@@ -2149,6 +2156,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
}
update();
accept_event();
+ ensure_cursor_is_visible();
if (dobreak) {
break;