Skip to content

Commit d83bae4

Browse files
FIX - RelativeCursorPosition Changed<> query filter (#20102)
## Problem This pseudocode was triggering constantly, even with the Changed<> query filter. ```rust pub fn check_mouse_movement_system( relative_cursor_positions: Query< &RelativeCursorPosition, (Changed<RelativeCursorPosition>, With<Button>)>, ) {} ``` ## Solution - Added a check to prevent updating the value if it hasn't changed. --------- Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com>
1 parent 84936ca commit d83bae4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

crates/bevy_ui/src/focus.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ pub fn ui_focus_system(
267267
// Save the relative cursor position to the correct component
268268
if let Some(mut node_relative_cursor_position_component) = node.relative_cursor_position
269269
{
270-
*node_relative_cursor_position_component = relative_cursor_position_component;
270+
// Avoid triggering change detection when not necessary.
271+
node_relative_cursor_position_component
272+
.set_if_neq(relative_cursor_position_component);
271273
}
272274

273275
if contains_cursor {

0 commit comments

Comments
 (0)