summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorNikolay Neupokoev <nikolay@scgames.us>2019-04-18 15:50:35 -0700
committerNikolay Neupokoev <nikolay@scgames.us>2019-04-22 15:11:49 -0700
commitebe54833a9425ca5bed21def64d3e8aa66b1b788 (patch)
treef44e356ae85853f81a547dcb589911608e20ddfb /scene
parentf46899e92253c4457eb320a0b99b8481c964dc97 (diff)
Fix popup visibility for OptionButton, MenuButton and ColorPickerButton
Hide popup when its button or another parent object is hidden Fixes #26937
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/color_picker.cpp6
-rw-r--r--scene/gui/menu_button.cpp10
-rw-r--r--scene/gui/menu_button.h1
-rw-r--r--scene/gui/option_button.cpp5
4 files changed, 22 insertions, 0 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 7aca6acd00..7455c766fe 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -776,6 +776,12 @@ void ColorPickerButton::_notification(int p_what) {
if (p_what == MainLoop::NOTIFICATION_WM_QUIT_REQUEST && popup) {
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) {
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index b67d8c00d6..73367aadea 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -91,6 +91,16 @@ bool MenuButton::is_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() {
ClassDB::bind_method(D_METHOD("get_popup"), &MenuButton::get_popup);
diff --git a/scene/gui/menu_button.h b/scene/gui/menu_button.h
index 794840035e..42e909d991 100644
--- a/scene/gui/menu_button.h
+++ b/scene/gui/menu_button.h
@@ -52,6 +52,7 @@ class MenuButton : public Button {
void _gui_input(Ref<InputEvent> p_event);
protected:
+ void _notification(int p_what);
static void _bind_methods();
public:
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index b9b270ce0c..20d780591d 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -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)));
arrow->draw(ci, ofs, clr);
+ } else if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
+
+ if (!is_visible_in_tree()) {
+ popup->hide();
+ }
}
}