Fix MenuButton hover switching not happening with submenus open
This commit is contained in:
parent
c320d9394d
commit
592eda7ad9
2 changed files with 25 additions and 3 deletions
|
@ -557,6 +557,21 @@ void PopupMenu::_notification(int p_what) {
|
||||||
mouse_over = -1;
|
mouse_over = -1;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < items.size(); i++) {
|
||||||
|
if (items[i].submenu == "")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Node *n = get_node(items[i].submenu);
|
||||||
|
if (!n)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
PopupMenu *pm = Object::cast_to<PopupMenu>(n);
|
||||||
|
if (!pm || !pm->is_visible())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
pm->hide();
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1012,8 +1027,7 @@ bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_fo
|
||||||
code |= KEY_MASK_SHIFT;
|
code |= KEY_MASK_SHIFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
int il = items.size();
|
for (int i = 0; i < items.size(); i++) {
|
||||||
for (int i = 0; i < il; i++) {
|
|
||||||
if (is_item_disabled(i) || items[i].shortcut_is_disabled)
|
if (is_item_disabled(i) || items[i].shortcut_is_disabled)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -1859,8 +1859,16 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
||||||
MenuButton *popup_menu_parent = NULL;
|
MenuButton *popup_menu_parent = NULL;
|
||||||
MenuButton *menu_button = Object::cast_to<MenuButton>(over);
|
MenuButton *menu_button = Object::cast_to<MenuButton>(over);
|
||||||
|
|
||||||
if (popup_menu)
|
if (popup_menu) {
|
||||||
popup_menu_parent = Object::cast_to<MenuButton>(popup_menu->get_parent());
|
popup_menu_parent = Object::cast_to<MenuButton>(popup_menu->get_parent());
|
||||||
|
if (!popup_menu_parent) {
|
||||||
|
// Go through the parents to see if there's a MenuButton at the end.
|
||||||
|
while (Object::cast_to<PopupMenu>(popup_menu->get_parent())) {
|
||||||
|
popup_menu = Object::cast_to<PopupMenu>(popup_menu->get_parent());
|
||||||
|
}
|
||||||
|
popup_menu_parent = Object::cast_to<MenuButton>(popup_menu->get_parent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If the mouse is over a menu button, this menu will open automatically
|
// If the mouse is over a menu button, this menu will open automatically
|
||||||
// if there is already a pop-up menu open at the same hierarchical level.
|
// if there is already a pop-up menu open at the same hierarchical level.
|
||||||
|
|
Loading…
Reference in a new issue