Merge pull request #13351 from poke1024/fix12451_2

Make click on arrow properly open and close property editor modals
This commit is contained in:
Rémi Verschelde 2017-12-10 11:58:36 +01:00 committed by GitHub
commit 7d735da6aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 31 additions and 0 deletions

View File

@ -1939,6 +1939,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");
@ -4276,6 +4277,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

@ -1646,6 +1646,8 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
} else {
bool is_handled = false;
_gui_sort_modal_stack();
while (!gui.modal_stack.empty()) {
@ -1663,11 +1665,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;
/*