diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index cd2d83fe2..73cee40f4 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -557,6 +557,7 @@ impl EpiIntegration { } } + #[allow(clippy::unused_self)] pub fn save(&mut self, _app: &mut dyn epi::App, _window: &winit::window::Window) { #[cfg(feature = "persistence")] if let Some(storage) = self.frame.storage_mut() { diff --git a/crates/egui/src/input_state.rs b/crates/egui/src/input_state.rs index 67cc06318..1b49757bc 100644 --- a/crates/egui/src/input_state.rs +++ b/crates/egui/src/input_state.rs @@ -894,8 +894,9 @@ impl PointerState { } /// If the pointer button is down, will it register as a click when released? - #[inline(always)] - pub(crate) fn could_any_button_be_click(&self) -> bool { + /// + /// See also [`Self::is_decidedly_dragging`]. + pub fn could_any_button_be_click(&self) -> bool { if !self.any_down() { return false; } @@ -913,6 +914,22 @@ impl PointerState { true } + /// Just because the mouse is down doesn't mean we are dragging. + /// We could be at the start of a click. + /// But if the mouse is down long enough, or has moved far enough, + /// then we consider it a drag. + /// + /// This function can return true on the same frame the drag is released, + /// but NOT on the first frame it was started. + /// + /// See also [`Self::could_any_button_be_click`]. + pub fn is_decidedly_dragging(&self) -> bool { + (self.any_down() || self.any_released()) + && !self.any_pressed() + && !self.could_any_button_be_click() + && !self.any_click() + } + /// Is the primary button currently down? #[inline(always)] pub fn primary_down(&self) -> bool { diff --git a/crates/egui/src/memory.rs b/crates/egui/src/memory.rs index 893db0fbf..db76f7e7c 100644 --- a/crates/egui/src/memory.rs +++ b/crates/egui/src/memory.rs @@ -477,6 +477,11 @@ impl Memory { self.interaction.drag_id = Some(id); } + #[inline(always)] + pub fn stop_dragging(&mut self) { + self.interaction.drag_id = None; + } + /// Forget window positions, sizes etc. /// Can be used to auto-layout windows. pub fn reset_areas(&mut self) {