You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Merge pull request #112095 from YeldhamDev/subpop_hl_fix
Fix `PopupMenu` losing item highlight when hovering submenus
This commit is contained in:
@@ -709,6 +709,9 @@ void PopupMenu::_input_from_window_internal(const Ref<InputEvent> &p_event) {
|
|||||||
if (!minimum_lifetime_timer->is_stopped()) {
|
if (!minimum_lifetime_timer->is_stopped()) {
|
||||||
// The mouse left the safe area, but came back again, so cancel the auto-closing.
|
// The mouse left the safe area, but came back again, so cancel the auto-closing.
|
||||||
minimum_lifetime_timer->stop();
|
minimum_lifetime_timer->stop();
|
||||||
|
if (PopupMenu *parent_pum = Object::cast_to<PopupMenu>(get_parent())) {
|
||||||
|
parent_pum->_hover_active_submenu_item();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouse_over == -1 && !item_clickable_area.has_point(m->get_position())) {
|
if (mouse_over == -1 && !item_clickable_area.has_point(m->get_position())) {
|
||||||
@@ -765,9 +768,12 @@ void PopupMenu::_mouse_over_update(const Point2 &p_over) {
|
|||||||
int id = (over < 0 || items[over].separator || items[over].disabled) ? -1 : (items[over].id >= 0 ? items[over].id : over);
|
int id = (over < 0 || items[over].separator || items[over].disabled) ? -1 : (items[over].id >= 0 ? items[over].id : over);
|
||||||
|
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
|
// Only remove the hover if there's no open submenu, or the mouse is in an item that can't be hovered.
|
||||||
|
if (over >= 0 || !(mouse_over >= 0 && items[mouse_over].submenu && items[mouse_over].submenu->is_visible())) {
|
||||||
mouse_over = -1;
|
mouse_over = -1;
|
||||||
queue_accessibility_update();
|
queue_accessibility_update();
|
||||||
control->queue_redraw();
|
control->queue_redraw();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1083,6 +1089,19 @@ Rect2i PopupMenu::_popup_adjust_rect() const {
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupMenu::_hover_active_submenu_item() {
|
||||||
|
for (int i = 0; i < items.size(); i++) {
|
||||||
|
if (items[i].submenu && items[i].submenu->is_visible()) {
|
||||||
|
if (mouse_over != i) {
|
||||||
|
mouse_over = i;
|
||||||
|
queue_accessibility_update();
|
||||||
|
control->queue_redraw();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PopupMenu::add_child_notify(Node *p_child) {
|
void PopupMenu::add_child_notify(Node *p_child) {
|
||||||
Window::add_child_notify(p_child);
|
Window::add_child_notify(p_child);
|
||||||
|
|
||||||
@@ -1271,7 +1290,7 @@ void PopupMenu::_notification(int p_what) {
|
|||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_WM_MOUSE_EXIT: {
|
case NOTIFICATION_WM_MOUSE_EXIT: {
|
||||||
if (mouse_over >= 0 && (!items[mouse_over].submenu || submenu_over != -1)) {
|
if (mouse_over >= 0 && (!items[mouse_over].submenu || !items[mouse_over].submenu->is_visible())) {
|
||||||
mouse_over = -1;
|
mouse_over = -1;
|
||||||
queue_accessibility_update();
|
queue_accessibility_update();
|
||||||
control->queue_redraw();
|
control->queue_redraw();
|
||||||
|
|||||||
@@ -228,6 +228,8 @@ class PopupMenu : public Popup {
|
|||||||
String _atr(int p_idx, const String &p_text) const;
|
String _atr(int p_idx, const String &p_text) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void _hover_active_submenu_item();
|
||||||
|
|
||||||
virtual void _pre_popup() override;
|
virtual void _pre_popup() override;
|
||||||
virtual Rect2i _popup_adjust_rect() const override;
|
virtual Rect2i _popup_adjust_rect() const override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user