Skip to main content

egui/data/input/
mouse_wheel_source.rs

1/// What is driving an [`crate::Event::MouseWheel`] event.
2///
3/// This lets a [`crate::ScrollArea`] treat the different kinds of scrolling differently,
4/// e.g. rubber-band past the edge while the fingers are on the trackpad,
5/// but bounce during the system-driven momentum phase.
6///
7/// This is about mice and trackpads. Touch screens don't produce [`crate::Event::MouseWheel`]
8/// events at all; they scroll by dragging with the pointer (see [`crate::Event::Touch`]).
9///
10/// ## Platform-specific
11/// * **macOS**: [`Self::Wheel`], [`Self::Trackpad`] or [`Self::Momentum`].
12/// * **Wayland, Windows, X11, web**: always [`Self::Unknown`], until winit reports the source.
13#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
14#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
15pub enum MouseWheelSource {
16    /// The platform doesn't say.
17    Unknown,
18
19    /// A physical wheel, usually on a mouse.
20    Wheel,
21
22    /// Fingers moving on a trackpad (or similar touch surface, like a Magic Mouse).
23    ///
24    /// Not a touch screen: those scroll by dragging with the pointer, see [`crate::Event::Touch`].
25    ///
26    /// On platforms that report a [`crate::TouchPhase`], the fingers are on the trackpad
27    /// from [`crate::TouchPhase::Start`] until [`crate::TouchPhase::End`].
28    Trackpad,
29
30    /// The system is continuing a finger scroll after the fingers were lifted,
31    /// with decaying speed, such as the "momentum phase" on macOS.
32    ///
33    /// On platforms that report a [`crate::TouchPhase`], this gets its own
34    /// [`crate::TouchPhase::Start`] … [`crate::TouchPhase::End`] cycle after the finger one.
35    Momentum,
36}