summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/menu_button.cpp11
-rw-r--r--scene/gui/option_button.cpp5
2 files changed, 11 insertions, 5 deletions
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index a03db82332..e6e17cc881 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -86,6 +86,11 @@ void MenuButton::_popup_visibility_changed(bool p_visible) {
}
void MenuButton::pressed() {
+ if (popup->is_visible()) {
+ popup->hide();
+ return;
+ }
+
emit_signal(SNAME("about_to_popup"));
Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
@@ -103,11 +108,7 @@ void MenuButton::pressed() {
popup->set_current_index(0);
}
- if (popup->is_visible()) {
- popup->hide();
- } else {
- popup->popup();
- }
+ popup->popup();
}
void MenuButton::gui_input(const Ref<InputEvent> &p_event) {
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 931dffe3bb..881acdbf3a 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -198,6 +198,11 @@ void OptionButton::_selected(int p_which) {
}
void OptionButton::pressed() {
+ if (popup->is_visible()) {
+ popup->hide();
+ return;
+ }
+
Size2 size = get_size() * get_viewport()->get_canvas_transform().get_scale();
popup->set_position(get_screen_position() + Size2(0, size.height * get_global_transform().get_scale().y));
popup->set_size(Size2(size.width, 0));