ui_automation/
click.rs

1// Copyright (C) 2024 Tristan Gerritsen <tristan@thewoosh.org>
2// All Rights Reserved.
3
4#[derive(Debug, Default, Clone)]
5pub struct ClickRequest {
6    position: ClickPosition,
7    button: MouseButton,
8}
9
10impl ClickRequest {
11    pub fn new(position: ClickPosition, button: MouseButton) -> Self {
12        Self {
13            position,
14            button,
15        }
16    }
17
18    #[must_use]
19    pub const fn position(&self) -> ClickPosition {
20        self.position
21    }
22
23    #[must_use]
24    pub const fn button(&self) -> MouseButton {
25        self.button
26    }
27}
28
29#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
30pub enum ClickPosition {
31    /// Click at the top-level position of the element.
32    Origin,
33
34    /// Click at the center of the element.
35    #[default]
36    Center,
37}
38
39#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
40pub enum MouseButton {
41    /// The left mouse button.
42    #[default]
43    Left,
44
45    /// The middle mouse button, usually the scroll wheel button.
46    Middle,
47
48    /// The right mouse button.
49    Right,
50}