Fix popup visibility for OptionButton, MenuButton and ColorPickerButton
Hide popup when its button or another parent object is hidden Fixes #26937
This commit is contained in:
parent
f46899e922
commit
ebe54833a9
@ -776,6 +776,12 @@ void ColorPickerButton::_notification(int p_what) {
|
|||||||
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST && popup) {
|
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST && popup) {
|
||||||
popup->hide();
|
popup->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
|
||||||
|
if (popup && !is_visible_in_tree()) {
|
||||||
|
popup->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPickerButton::set_pick_color(const Color &p_color) {
|
void ColorPickerButton::set_pick_color(const Color &p_color) {
|
||||||
|
@ -91,6 +91,16 @@ bool MenuButton::is_switch_on_hover() {
|
|||||||
return switch_on_hover;
|
return switch_on_hover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuButton::_notification(int p_what) {
|
||||||
|
|
||||||
|
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
|
||||||
|
|
||||||
|
if (!is_visible_in_tree()) {
|
||||||
|
popup->hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuButton::_bind_methods() {
|
void MenuButton::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_popup"), &MenuButton::get_popup);
|
ClassDB::bind_method(D_METHOD("get_popup"), &MenuButton::get_popup);
|
||||||
|
@ -52,6 +52,7 @@ class MenuButton : public Button {
|
|||||||
void _gui_input(Ref<InputEvent> p_event);
|
void _gui_input(Ref<InputEvent> p_event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -72,6 +72,11 @@ void OptionButton::_notification(int p_what) {
|
|||||||
|
|
||||||
Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
|
Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2)));
|
||||||
arrow->draw(ci, ofs, clr);
|
arrow->draw(ci, ofs, clr);
|
||||||
|
} else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
|
||||||
|
|
||||||
|
if (!is_visible_in_tree()) {
|
||||||
|
popup->hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user