web_event/mouse_event/double_click/
mod.rs

1use std::fmt::{Debug, Formatter};
2use wasm_bindgen::JsCast;
3use web_sys::{Event, EventTarget, MouseEvent};
4
5/// The event occurs when the user double-clicks on an element
6/// - Bubbles: Yes
7/// - Cancelable: Yes
8/// - Event type: [`MouseEvent`]
9/// - Supported HTML tags: All HTML elements, EXCEPT: `<base>`, `<bdo>`, `<br>`, `<head>`, `<html>`,
10///   `<iframe>`, `<meta>`, `<param>`, `<script>`, `<style>`, and `<title>`.
11#[derive(Clone)]
12pub struct OnDoubleClick {
13    inner: MouseEvent,
14}
15
16impl Debug for OnDoubleClick {
17    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
18        f.write_str("OnDoubleClickEvent")
19    }
20}
21
22impl From<Event> for OnDoubleClick {
23    fn from(e: Event) -> Self {
24        let event: MouseEvent = e.unchecked_into();
25        Self { inner: event }
26    }
27}
28
29impl OnDoubleClick {
30    /// Getter for the `screenX` field of this object.
31    ///
32    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenX)
33    #[inline]
34    pub fn screen_x(&self) -> i32 {
35        self.inner.screen_x()
36    }
37
38    /// Getter for the `screenY` field of this object.
39    ///
40    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/screenY)
41    #[inline]
42    pub fn screen_y(&self) -> i32 {
43        self.inner.screen_y()
44    }
45    /// Getter for the `clientX` field of this object.
46    ///
47    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX)
48    #[inline]
49    pub fn client_x(&self) -> i32 {
50        self.inner.client_x()
51    }
52
53    /// Getter for the `clientY` field of this object.
54    ///
55    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientY)
56    #[inline]
57    pub fn client_y(&self) -> i32 {
58        self.inner.client_y()
59    }
60    /// Getter for the `x` field of this object.
61    ///
62    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/x)
63    #[inline]
64    pub fn x(&self) -> i32 {
65        self.inner.x()
66    }
67
68    /// Getter for the `y` field of this object.
69    ///
70    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/y)
71    #[inline]
72    pub fn y(&self) -> i32 {
73        self.inner.y()
74    }
75
76    /// Getter for the `offsetX` field of this object.
77    ///
78    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetX)
79    #[inline]
80    pub fn offset_x(&self) -> i32 {
81        self.inner.offset_x()
82    }
83
84    /// Getter for the `offsetY` field of this object.
85    ///
86    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/offsetY)
87    #[inline]
88    pub fn offset_y(&self) -> i32 {
89        self.inner.offset_y()
90    }
91
92    /// Getter for the `ctrlKey` field of this object.
93    ///
94    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/ctrlKey)
95    #[inline]
96    pub fn ctrl_key(&self) -> bool {
97        self.inner.ctrl_key()
98    }
99
100    /// Getter for the `shiftKey` field of this object.
101    ///
102    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/shiftKey)
103    #[inline]
104    pub fn shift_key(&self) -> bool {
105        self.inner.shift_key()
106    }
107
108    /// Getter for the `altKey` field of this object.
109    ///
110    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/altKey)
111    pub fn alt_key(&self) -> bool {
112        self.inner.alt_key()
113    }
114
115    /// Getter for the `metaKey` field of this object.
116    ///
117    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/metaKey)
118    #[inline]
119    pub fn meta_key(&self) -> bool {
120        self.inner.meta_key()
121    }
122
123    /// Getter for the `button` field of this object.
124    ///
125    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button)
126    #[inline]
127    pub fn button(&self) -> i16 {
128        self.inner.button()
129    }
130
131    /// Getter for the `buttons` field of this object.
132    ///
133    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons)
134    #[inline]
135    pub fn buttons(&self) -> u16 {
136        self.inner.buttons()
137    }
138    /// Getter for the `relatedTarget` field of this object.
139    ///
140    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/relatedTarget)
141    #[inline]
142    pub fn related_target(&self) -> Option<EventTarget> {
143        self.inner.related_target()
144    }
145
146    /// Getter for the `region` field of this object.
147    ///
148    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/region)
149    #[inline]
150    pub fn region(&self) -> Option<String> {
151        self.inner.region()
152    }
153
154    /// Getter for the `movementX` field of this object.
155    ///
156    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementX)
157    #[inline]
158    pub fn movement_x(&self) -> i32 {
159        self.inner.movement_x()
160    }
161
162    /// Getter for the `movementY` field of this object.
163    ///
164    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/movementY)
165    #[inline]
166    pub fn movement_y(&self) -> i32 {
167        self.inner.movement_y()
168    }
169}