From d5bb85b2459c0296d07316dcb96cf10e800ee71f Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 20 Feb 2021 09:24:50 +0100 Subject: [PATCH] Add InputState::is_still to compliment InputState::is_moving --- egui/src/input_state.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/egui/src/input_state.rs b/egui/src/input_state.rs index 32119867..92039d40 100644 --- a/egui/src/input_state.rs +++ b/egui/src/input_state.rs @@ -427,8 +427,14 @@ impl PointerState { self.latest_pos.is_some() } - /// Is the pointer currently moving? + /// Is the pointer currently still? /// This is smoothed so a few frames of stillness is required before this returns `true`. + pub fn is_still(&self) -> bool { + self.velocity == Vec2::ZERO + } + + /// Is the pointer currently moving? + /// This is smoothed so a few frames of stillness is required before this returns `false`. pub fn is_moving(&self) -> bool { self.velocity != Vec2::ZERO }