summaryrefslogtreecommitdiff
path: root/scene/gui/popup_menu.cpp
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2016-04-06 15:37:57 +0300
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2016-04-06 15:42:50 +0300
commitb7d79c93f47c6d5e6d9e4f50c546cd521866703a (patch)
tree8372b1c273237477661dc8fed3328c93ea9fdaeb /scene/gui/popup_menu.cpp
parent4af1839073261d913ef53bb6f81d2a0cb486d39b (diff)
Fix PopupMenu and MenuButton not activating items with shortcut inside submenus
Diffstat (limited to 'scene/gui/popup_menu.cpp')
-rw-r--r--scene/gui/popup_menu.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 3329d24890..819885809b 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -740,15 +740,33 @@ int PopupMenu::get_item_count() const {
return items.size();
}
-int PopupMenu::find_item_by_accelerator(uint32_t p_accel) const {
+bool PopupMenu::activate_item_by_accelerator(uint32_t p_accel) {
int il=items.size();
for(int i=0;i<il;i++) {
+ if (is_item_disabled(i))
+ continue;
- if (items[i].accel==p_accel)
- return i;
+ if (items[i].accel==p_accel) {
+ activate_item(i);
+ return true;
+ }
+
+ if (items[i].submenu!="") {
+ Node* n = get_node(items[i].submenu);
+ if(!n)
+ continue;
+
+ PopupMenu* pm = n->cast_to<PopupMenu>();
+ if(!pm)
+ continue;
+
+ if(pm->activate_item_by_accelerator(p_accel)) {
+ return true;
+ }
+ }
}
- return -1;
+ return false;
}
void PopupMenu::activate_item(int p_item) {