iced_core/mouse/
event.rs

1use crate::Point;
2
3use super::Button;
4
5/// A mouse event.
6///
7/// _**Note:** This type is largely incomplete! If you need to track
8/// additional events, feel free to [open an issue] and share your use case!_
9///
10/// [open an issue]: https://github.com/iced-rs/iced/issues
11#[derive(Debug, Clone, Copy, PartialEq)]
12pub enum Event {
13    /// The mouse cursor entered the window.
14    CursorEntered,
15
16    /// The mouse cursor left the window.
17    CursorLeft,
18
19    /// The mouse cursor was moved
20    CursorMoved {
21        /// The new position of the mouse cursor
22        position: Point,
23    },
24
25    /// A mouse button was pressed.
26    ButtonPressed(Button),
27
28    /// A mouse button was released.
29    ButtonReleased(Button),
30
31    /// The mouse wheel was scrolled.
32    WheelScrolled {
33        /// The scroll movement.
34        delta: ScrollDelta,
35    },
36}
37
38/// A scroll movement.
39#[derive(Debug, Clone, Copy, PartialEq)]
40pub enum ScrollDelta {
41    /// A line-based scroll movement
42    Lines {
43        /// The number of horizontal lines scrolled
44        x: f32,
45
46        /// The number of vertical lines scrolled
47        y: f32,
48    },
49    /// A pixel-based scroll movement
50    Pixels {
51        /// The number of horizontal pixels scrolled
52        x: f32,
53        /// The number of vertical pixels scrolled
54        y: f32,
55    },
56}