electron_sys/interface/
mouse_input_event.rs

1use js_sys::JsString;
2use wasm_bindgen::prelude::*;
3
4// NOTE: extends InputEvent
5
6#[wasm_bindgen]
7#[derive(Clone, Debug, PartialEq)]
8pub struct MouseInputEvent {
9    acceleration_ratio_x: Option<i32>,
10    acceleration_ratio_y: Option<i32>,
11    can_scroll: Option<bool>,
12    delta_x: Option<i32>,
13    delta_y: Option<i32>,
14    has_precise_scrolling_deltas: Option<bool>,
15    kind: JsString,
16    modifiers: Box<[JsValue]>,
17    wheel_ticks_x: Option<i32>,
18    wheel_ticks_y: Option<i32>,
19}
20
21#[wasm_bindgen]
22impl MouseInputEvent {
23    #[allow(clippy::too_many_arguments)]
24    #[wasm_bindgen(constructor)]
25    pub fn new(
26        acceleration_ratio_x: Option<i32>,
27        acceleration_ratio_y: Option<i32>,
28        can_scroll: Option<bool>,
29        delta_x: Option<i32>,
30        delta_y: Option<i32>,
31        has_precise_scrolling_deltas: Option<bool>,
32        kind: JsString,
33        modifiers: Box<[JsValue]>,
34        wheel_ticks_x: Option<i32>,
35        wheel_ticks_y: Option<i32>,
36    ) -> MouseInputEvent {
37        MouseInputEvent {
38            acceleration_ratio_x,
39            acceleration_ratio_y,
40            can_scroll,
41            delta_x,
42            delta_y,
43            has_precise_scrolling_deltas,
44            kind,
45            modifiers,
46            wheel_ticks_x,
47            wheel_ticks_y,
48        }
49    }
50
51    #[wasm_bindgen(getter, js_name = "accelerationRatioX")]
52    pub fn acceleration_ratio_x(&self) -> Option<i32> {
53        self.acceleration_ratio_x
54    }
55
56    #[wasm_bindgen(setter)]
57    pub fn set_acceleration_ratio_x(&mut self, value: Option<i32>) {
58        self.acceleration_ratio_x = value;
59    }
60
61    #[wasm_bindgen(getter, js_name = "accelerationRatioY")]
62    pub fn acceleration_ratio_y(&self) -> Option<i32> {
63        self.acceleration_ratio_y
64    }
65
66    #[wasm_bindgen(setter)]
67    pub fn set_acceleration_ratio_y(&mut self, value: Option<i32>) {
68        self.acceleration_ratio_y = value;
69    }
70
71    #[wasm_bindgen(getter, js_name = "canScroll")]
72    pub fn can_scroll(&self) -> Option<bool> {
73        self.can_scroll
74    }
75
76    #[wasm_bindgen(setter)]
77    pub fn set_can_scroll(&mut self, value: Option<bool>) {
78        self.can_scroll = value;
79    }
80
81    #[wasm_bindgen(getter, js_name = "deltaX")]
82    pub fn delta_x(&self) -> Option<i32> {
83        self.delta_x
84    }
85
86    #[wasm_bindgen(setter)]
87    pub fn set_delta_x(&mut self, value: Option<i32>) {
88        self.delta_x = value;
89    }
90
91    #[wasm_bindgen(getter, js_name = "deltaY")]
92    pub fn delta_y(&self) -> Option<i32> {
93        self.delta_y
94    }
95
96    #[wasm_bindgen(setter)]
97    pub fn set_delta_y(&mut self, value: Option<i32>) {
98        self.delta_y = value;
99    }
100
101    #[wasm_bindgen(getter, js_name = "hasPreciseScrollingDeltas")]
102    pub fn has_precise_scrolling_deltas(&self) -> Option<bool> {
103        self.has_precise_scrolling_deltas
104    }
105
106    #[wasm_bindgen(setter)]
107    pub fn set_has_precise_scrolling_deltas(&mut self, value: Option<bool>) {
108        self.has_precise_scrolling_deltas = value;
109    }
110
111    #[wasm_bindgen(getter)]
112    pub fn kind(&self) -> JsString {
113        self.kind.clone()
114    }
115
116    #[wasm_bindgen(setter)]
117    pub fn set_kind(&mut self, value: JsString) {
118        self.kind = value;
119    }
120
121    #[wasm_bindgen(getter)]
122    pub fn modifiers(&self) -> Box<[JsValue]> {
123        self.modifiers.clone()
124    }
125
126    #[wasm_bindgen(setter)]
127    pub fn set_modifiers(&mut self, value: Box<[JsValue]>) {
128        self.modifiers = value;
129    }
130
131    #[wasm_bindgen(getter, js_name = "wheelTicksX")]
132    pub fn wheel_ticks_x(&self) -> Option<i32> {
133        self.wheel_ticks_x
134    }
135
136    #[wasm_bindgen(setter)]
137    pub fn set_wheel_ticks_x(&mut self, value: Option<i32>) {
138        self.wheel_ticks_x = value;
139    }
140
141    #[wasm_bindgen(getter, js_name = "wheelTicksY")]
142    pub fn wheel_ticks_y(&self) -> Option<i32> {
143        self.wheel_ticks_y
144    }
145
146    #[wasm_bindgen(setter)]
147    pub fn set_wheel_ticks_y(&mut self, value: Option<i32>) {
148        self.wheel_ticks_y = value;
149    }
150}