Skip to main content

euv_core/window/input/
impl.rs

1use super::*;
2
3/// Convenience constructors for `PointerEvent`.
4impl PointerEvent {
5    /// Creates a primary mouse pointer event at logical `(x, y)`.
6    ///
7    /// # Arguments
8    ///
9    /// - `f32` - Logical X coordinate.
10    /// - `f32` - Logical Y coordinate.
11    ///
12    /// # Returns
13    ///
14    /// - `Self` - Mouse pointer event.
15    #[must_use]
16    pub fn mouse(x: f32, y: f32) -> Self {
17        Self::new(
18            0,
19            PointerDevice::Mouse,
20            Point::new(x, y),
21            PointerButton::Primary,
22            1.0,
23            Modifiers::default(),
24        )
25    }
26
27    /// Creates a touch pointer event for `finger_id` at logical `(x, y)`.
28    ///
29    /// # Arguments
30    ///
31    /// - `u64` - Touch contact identifier.
32    /// - `f32` - Logical X coordinate.
33    /// - `f32` - Logical Y coordinate.
34    ///
35    /// # Returns
36    ///
37    /// - `Self` - Touch pointer event.
38    #[must_use]
39    pub fn touch(finger_id: u64, x: f32, y: f32) -> Self {
40        Self::new(
41            finger_id,
42            PointerDevice::Touch,
43            Point::new(x, y),
44            PointerButton::Primary,
45            1.0,
46            Modifiers::default(),
47        )
48    }
49}