summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Alexsander Silva Dias <michaelalexsander@protonmail.com>2017-12-16 20:54:44 -0200
committerMichael Alexsander Silva Dias <michaelalexsander@protonmail.com>2017-12-16 20:57:26 -0200
commit7e38db631f0d5577457a68c5dbc7c09a308bb18d (patch)
tree8705ab9d734d4d9a0386ca4c33a9f5ae039aca37
parent1e2a8132f333245bf3f77244b83e625a56418067 (diff)
More changes to PopupMenu's submenu keyboard handling.
-rw-r--r--scene/gui/popup_menu.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 698676cc39..62f2b15ddd 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -211,11 +211,6 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
mouse_over = i;
update();
-
- if (items[i].submenu != "" && submenu_over != i) {
- submenu_over = i;
- submenu_timer->start();
- }
break;
}
}
@@ -231,20 +226,40 @@ void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
mouse_over = i;
update();
-
- if (items[i].submenu != "" && submenu_over != i) {
- submenu_over = i;
- submenu_timer->start();
- }
break;
}
}
} break;
+
+ case KEY_LEFT: {
+
+ Node *n = get_parent();
+ if (!n)
+ break;
+
+ PopupMenu *pm = Object::cast_to<PopupMenu>(n);
+ if (!pm)
+ break;
+
+ hide();
+ } break;
+
+ case KEY_RIGHT: {
+
+ if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator && items[mouse_over].submenu != "" && submenu_over != mouse_over)
+ _activate_submenu(mouse_over);
+ } break;
+
case KEY_ENTER:
case KEY_KP_ENTER: {
if (mouse_over >= 0 && mouse_over < items.size() && !items[mouse_over].separator) {
+ if (items[mouse_over].submenu != "" && submenu_over != mouse_over) {
+ _activate_submenu(mouse_over);
+ break;
+ }
+
activate_item(mouse_over);
}
} break;