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