Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions crates/bevy_picking/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,15 @@ pub struct PointerButtonState {
pub dragging_over: HashMap<Entity, HitData>,
}

impl PointerButtonState {
/// Clears all press and drag data tracked for this button on its pointer.
pub fn clear(&mut self) {
self.pressing.clear();
self.dragging.clear();
self.dragging_over.clear();
}
}

/// State for all pointers.
#[derive(Debug, Clone, Default, Resource)]
pub struct PointerState {
Expand Down Expand Up @@ -379,9 +388,7 @@ impl PointerState {
pub fn clear(&mut self, pointer_id: PointerId) {
for button in PointerButton::iter() {
if let Some(state) = self.pointer_buttons.get_mut(&(pointer_id, button)) {
state.pressing.clear();
state.dragging.clear();
state.dragging_over.clear();
state.clear()
}
}
}
Expand Down Expand Up @@ -699,9 +706,7 @@ pub fn pointer_events(
}

// Finally, we can clear the state of everything relating to presses or drags.
state.pressing.clear();
state.dragging.clear();
state.dragging_over.clear();
state.clear();
}
// Moved
PointerAction::Move { delta } => {
Expand Down
Loading