fix certain popup close clicks with popup buttons

This commit is contained in:
Bernhard Liebl 2017-11-22 09:43:40 +01:00
parent d055031c73
commit efc3ffb816
6 changed files with 31 additions and 0 deletions

View file

@ -1948,6 +1948,7 @@ CustomPropertyEditor::CustomPropertyEditor() {
type_button->get_popup()->connect("id_pressed", this, "_type_create_selected");
menu = memnew(PopupMenu);
menu->set_pass_on_modal_close_click(false);
add_child(menu);
menu->connect("id_pressed", this, "_menu_option");
@ -4288,6 +4289,7 @@ PropertyEditor::PropertyEditor() {
set_physics_process(true);
custom_editor = memnew(CustomPropertyEditor);
custom_editor->set_pass_on_modal_close_click(false);
add_child(custom_editor);
tree->connect("custom_popup_edited", this, "_custom_editor_request");

View file

@ -2470,6 +2470,16 @@ Control::MouseFilter Control::get_mouse_filter() const {
return data.mouse_filter;
}
void Control::set_pass_on_modal_close_click(bool p_pass_on) {
data.pass_on_modal_close_click = p_pass_on;
}
bool Control::pass_on_modal_close_click() const {
return data.pass_on_modal_close_click;
}
Control *Control::get_focus_owner() const {
ERR_FAIL_COND_V(!is_inside_tree(), NULL);
@ -2934,6 +2944,7 @@ Control::Control() {
data.parent = NULL;
data.mouse_filter = MOUSE_FILTER_STOP;
data.pass_on_modal_close_click = true;
data.SI = NULL;
data.MI = NULL;

View file

@ -165,6 +165,8 @@ private:
bool pending_min_size_update;
Point2 custom_minimum_size;
bool pass_on_modal_close_click;
MouseFilter mouse_filter;
bool clip_contents;
@ -401,6 +403,9 @@ public:
void set_mouse_filter(MouseFilter p_filter);
MouseFilter get_mouse_filter() const;
void set_pass_on_modal_close_click(bool p_pass_on);
bool pass_on_modal_close_click() const;
/* SKINNING */
void add_icon_override(const StringName &p_name, const Ref<Texture> &p_icon);

View file

@ -111,6 +111,7 @@ MenuButton::MenuButton() {
popup->hide();
add_child(popup);
popup->set_as_toplevel(true);
popup->set_pass_on_modal_close_click(false);
connect("button_up", popup, "call_deferred", make_binds("grab_click_focus"));
set_process_unhandled_key_input(true);
set_action_mode(ACTION_MODE_BUTTON_PRESS);

View file

@ -323,6 +323,7 @@ OptionButton::OptionButton() {
popup = memnew(PopupMenu);
popup->hide();
popup->set_as_toplevel(true);
popup->set_pass_on_modal_close_click(false);
add_child(popup);
popup->connect("id_pressed", this, "_selected");

View file

@ -1649,6 +1649,8 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
} else {
bool is_handled = false;
_gui_sort_modal_stack();
while (!gui.modal_stack.empty()) {
@ -1666,11 +1668,20 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
top->notification(Control::NOTIFICATION_MODAL_CLOSE);
top->_modal_stack_remove();
top->hide();
if (!top->pass_on_modal_close_click()) {
is_handled = true;
}
} else {
break;
}
}
if (is_handled) {
get_tree()->set_input_as_handled();
return;
}
//Matrix32 parent_xform;
/*