mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Fix and rename mouse filter recursive behavior
and focus mode recursive behavior.
This commit is contained in:
@@ -750,7 +750,7 @@ void Viewport::_process_picking() {
|
||||
#endif // PHYSICS_2D_DISABLED
|
||||
|
||||
SubViewportContainer *parent_svc = Object::cast_to<SubViewportContainer>(get_parent());
|
||||
bool parent_ignore_mouse = (parent_svc && parent_svc->get_mouse_filter_with_recursive() == Control::MOUSE_FILTER_IGNORE);
|
||||
bool parent_ignore_mouse = (parent_svc && parent_svc->get_mouse_filter_with_override() == Control::MOUSE_FILTER_IGNORE);
|
||||
bool create_passive_hover_event = true;
|
||||
if (gui.mouse_over || parent_ignore_mouse) {
|
||||
// When the mouse is over a Control node, passive hovering would cause input events for Colliders, that are behind Control nodes.
|
||||
@@ -1499,7 +1499,7 @@ String Viewport::_gui_get_tooltip(Control *p_control, const Vector2 &p_pos, Cont
|
||||
|
||||
// Otherwise, we check parent controls unless some conditions prevent it.
|
||||
|
||||
if (p_control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
|
||||
if (p_control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP) {
|
||||
break;
|
||||
}
|
||||
if (p_control->is_set_as_top_level()) {
|
||||
@@ -1670,14 +1670,14 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu
|
||||
while (ci) {
|
||||
Control *control = Object::cast_to<Control>(ci);
|
||||
if (control) {
|
||||
if (control->data.mouse_filter != Control::MOUSE_FILTER_IGNORE) {
|
||||
if (control->get_mouse_filter_with_override() != Control::MOUSE_FILTER_IGNORE) {
|
||||
control->_call_gui_input(ev);
|
||||
}
|
||||
|
||||
if (!control->is_inside_tree() || control->is_set_as_top_level()) {
|
||||
break;
|
||||
}
|
||||
if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP && is_pointer_event && !(is_scroll_event && control->data.force_pass_scroll_events)) {
|
||||
if (control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP && is_pointer_event && !(is_scroll_event && control->data.force_pass_scroll_events)) {
|
||||
// Mouse, ScreenDrag and ScreenTouch events are stopped by default with MOUSE_FILTER_STOP, unless we have a scroll event and force_pass_scroll_events set to true
|
||||
set_input_as_handled();
|
||||
break;
|
||||
@@ -1703,7 +1703,7 @@ void Viewport::_gui_call_notification(Control *p_control, int p_what) {
|
||||
while (ci) {
|
||||
Control *control = Object::cast_to<Control>(ci);
|
||||
if (control) {
|
||||
if (control->data.mouse_filter != Control::MOUSE_FILTER_IGNORE) {
|
||||
if (control->get_mouse_filter_with_override() != Control::MOUSE_FILTER_IGNORE) {
|
||||
control->notification(p_what);
|
||||
}
|
||||
|
||||
@@ -1714,7 +1714,7 @@ void Viewport::_gui_call_notification(Control *p_control, int p_what) {
|
||||
if (!control->is_inside_tree() || control->is_set_as_top_level()) {
|
||||
break;
|
||||
}
|
||||
if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
|
||||
if (control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1784,7 +1784,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_
|
||||
}
|
||||
}
|
||||
|
||||
if (!c || c->data.mouse_filter == Control::MOUSE_FILTER_IGNORE) {
|
||||
if (!c || c->get_mouse_filter_with_override() == Control::MOUSE_FILTER_IGNORE) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1816,7 +1816,7 @@ bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_che
|
||||
return true;
|
||||
}
|
||||
|
||||
if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
|
||||
if (control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1882,7 +1882,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
||||
while (ci) {
|
||||
Control *control = Object::cast_to<Control>(ci);
|
||||
if (control) {
|
||||
if (control->get_focus_mode_with_recursive() != Control::FOCUS_NONE) {
|
||||
if (control->get_focus_mode_with_override() != Control::FOCUS_NONE) {
|
||||
// Grabbing unhovered focus can cause issues when mouse is dragged
|
||||
// with another button held down.
|
||||
if (control != gui.key_focus && gui.mouse_over_hierarchy.has(control)) {
|
||||
@@ -1891,7 +1891,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
|
||||
if (control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1977,7 +1977,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
||||
section_root->gui.global_dragging = false;
|
||||
}
|
||||
|
||||
if (control->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
|
||||
if (control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2069,7 +2069,7 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
||||
if (cursor_shape != Control::CURSOR_ARROW) {
|
||||
break;
|
||||
}
|
||||
if (c->data.mouse_filter == Control::MOUSE_FILTER_STOP) {
|
||||
if (c->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP) {
|
||||
break;
|
||||
}
|
||||
if (c->is_set_as_top_level()) {
|
||||
@@ -2503,7 +2503,7 @@ void Viewport::_gui_update_mouse_over() {
|
||||
int found = gui.mouse_over_hierarchy.find(ancestor_control);
|
||||
if (found >= 0) {
|
||||
// Remove the node if the propagation chain has been broken or it is now MOUSE_FILTER_IGNORE.
|
||||
if (removing || ancestor_control->get_mouse_filter_with_recursive() == Control::MOUSE_FILTER_IGNORE) {
|
||||
if (removing || ancestor_control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_IGNORE) {
|
||||
needs_exit.push_back(found);
|
||||
}
|
||||
}
|
||||
@@ -2514,14 +2514,14 @@ void Viewport::_gui_update_mouse_over() {
|
||||
}
|
||||
reached_top = true;
|
||||
}
|
||||
if (!removing && ancestor_control->get_mouse_filter_with_recursive() != Control::MOUSE_FILTER_IGNORE) {
|
||||
if (!removing && ancestor_control->get_mouse_filter_with_override() != Control::MOUSE_FILTER_IGNORE) {
|
||||
new_mouse_over_hierarchy.push_back(ancestor_control);
|
||||
// Add the node if it was not found and it is now not MOUSE_FILTER_IGNORE.
|
||||
if (found < 0) {
|
||||
needs_enter.push_back(ancestor_control);
|
||||
}
|
||||
}
|
||||
if (ancestor_control->get_mouse_filter_with_recursive() == Control::MOUSE_FILTER_STOP) {
|
||||
if (ancestor_control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP) {
|
||||
// MOUSE_FILTER_STOP breaks the propagation chain.
|
||||
if (reached_top) {
|
||||
break;
|
||||
@@ -3182,7 +3182,7 @@ void Viewport::_update_mouse_over(Vector2 p_pos) {
|
||||
while (ancestor) {
|
||||
Control *ancestor_control = Object::cast_to<Control>(ancestor);
|
||||
if (ancestor_control) {
|
||||
if (ancestor_control->get_mouse_filter_with_recursive() != Control::MOUSE_FILTER_IGNORE) {
|
||||
if (ancestor_control->get_mouse_filter_with_override() != Control::MOUSE_FILTER_IGNORE) {
|
||||
int found = gui.mouse_over_hierarchy.find(ancestor_control);
|
||||
if (found >= 0) {
|
||||
common_ancestor = gui.mouse_over_hierarchy[found];
|
||||
@@ -3190,7 +3190,7 @@ void Viewport::_update_mouse_over(Vector2 p_pos) {
|
||||
}
|
||||
over_ancestors.push_back(ancestor_control);
|
||||
}
|
||||
if (ancestor_control->get_mouse_filter_with_recursive() == Control::MOUSE_FILTER_STOP) {
|
||||
if (ancestor_control->get_mouse_filter_with_override() == Control::MOUSE_FILTER_STOP) {
|
||||
// MOUSE_FILTER_STOP breaks the propagation chain.
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user