Skip to content

Commit

Permalink
Merge pull request #64768 from bruvzg/popups_hide_if_visible
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Aug 26, 2022
2 parents 7013c68 + cd095ab commit ac7b511
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 5 additions & 0 deletions editor/editor_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ void EditorPath::_add_children_to_popup(Object *p_obj, int p_depth) {
}

void EditorPath::_show_popup() {
if (sub_objects_menu->is_visible()) {
sub_objects_menu->hide();
return;
}

sub_objects_menu->clear();

Size2 size = get_size();
Expand Down
11 changes: 6 additions & 5 deletions scene/gui/menu_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions scene/gui/option_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit ac7b511

Please sign in to comment.