Merge pull request #64768 from bruvzg/popups_hide_if_visible

This commit is contained in:
Rémi Verschelde 2022-08-26 11:59:50 +02:00 committed by GitHub
commit ac7b5111f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 5 deletions

View File

@ -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();

View File

@ -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) {

View File

@ -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));