diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-05-17 23:50:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-17 23:50:55 +0200 |
commit | 5c79782c7e21c1ca795ef92bb780e1ec4b52a592 (patch) | |
tree | ea8e1532a0cd716f63d5c2eb4301fc80554148bc /scene/gui | |
parent | b052835ca31520ca787449c1dab440c8ea28f9f6 (diff) | |
parent | 6db8b7616de76b323b003292898a8a4ee6c6f936 (diff) |
Merge pull request #61088 from groud/keep_unhandled_events_on_pass
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/control.cpp | 20 | ||||
-rw-r--r-- | scene/gui/control.h | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index a0104387c9..5c5b2683a4 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -471,6 +471,13 @@ void Control::_validate_property(PropertyInfo &property) const { property.hint_string = hint_string; } + if (property.name == "mouse_force_pass_scroll_events") { + // Disable force pass if the control is not stopping the event. + if (data.mouse_filter != MOUSE_FILTER_STOP) { + property.usage |= PROPERTY_USAGE_READ_ONLY; + } + } + // Validate which positioning properties should be displayed depending on the parent and the layout mode. Node *parent_node = get_parent_control(); if (!parent_node) { @@ -2921,6 +2928,7 @@ int Control::get_v_size_flags() const { void Control::set_mouse_filter(MouseFilter p_filter) { ERR_FAIL_INDEX(p_filter, 3); data.mouse_filter = p_filter; + notify_property_list_changed(); update_configuration_warnings(); } @@ -2928,6 +2936,14 @@ Control::MouseFilter Control::get_mouse_filter() const { return data.mouse_filter; } +void Control::set_force_pass_scroll_events(bool p_force_pass_scroll_events) { + data.force_pass_scroll_events = p_force_pass_scroll_events; +} + +bool Control::is_force_pass_scroll_events() const { + return data.force_pass_scroll_events; +} + void Control::warp_mouse(const Point2 &p_position) { ERR_FAIL_COND(!is_inside_tree()); get_viewport()->warp_mouse(get_global_transform_with_canvas().xform(p_position)); @@ -3240,6 +3256,9 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_mouse_filter", "filter"), &Control::set_mouse_filter); ClassDB::bind_method(D_METHOD("get_mouse_filter"), &Control::get_mouse_filter); + ClassDB::bind_method(D_METHOD("set_force_pass_scroll_events", "force_pass_scroll_events"), &Control::set_force_pass_scroll_events); + ClassDB::bind_method(D_METHOD("is_force_pass_scroll_events"), &Control::is_force_pass_scroll_events); + ClassDB::bind_method(D_METHOD("set_clip_contents", "enable"), &Control::set_clip_contents); ClassDB::bind_method(D_METHOD("is_clipping_contents"), &Control::is_clipping_contents); @@ -3321,6 +3340,7 @@ void Control::_bind_methods() { ADD_GROUP("Mouse", "mouse_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_filter", PROPERTY_HINT_ENUM, "Stop,Pass,Ignore"), "set_mouse_filter", "get_mouse_filter"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "mouse_force_pass_scroll_events"), "set_force_pass_scroll_events", "is_force_pass_scroll_events"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_default_cursor_shape", PROPERTY_HINT_ENUM, "Arrow,I-Beam,Pointing Hand,Cross,Wait,Busy,Drag,Can Drop,Forbidden,Vertical Resize,Horizontal Resize,Secondary Diagonal Resize,Main Diagonal Resize,Move,Vertical Split,Horizontal Split,Help"), "set_default_cursor_shape", "get_default_cursor_shape"); ADD_GROUP("Theme", "theme_"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 65b71d74f8..43d49da055 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -190,6 +190,7 @@ private: Point2 custom_minimum_size; MouseFilter mouse_filter = MOUSE_FILTER_STOP; + bool force_pass_scroll_events = true; bool clip_contents = false; @@ -468,6 +469,9 @@ public: void set_mouse_filter(MouseFilter p_filter); MouseFilter get_mouse_filter() const; + void set_force_pass_scroll_events(bool p_force_pass_scroll_events); + bool is_force_pass_scroll_events() const; + /* SKINNING */ void begin_bulk_theme_override(); |