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
use js_sys::Array;
use std::fmt::{Debug, Formatter};
use wasm_bindgen::JsCast;
use web_sys::{Event, PointerEvent};

/// - Bubbles: Yes
/// - Cancelable: Yes
/// - Event type: MouseEvent
/// - Supported HTML tags: All HTML elements, EXCEPT: `<base>`, `<bdo>`, `<br>`, `<head>`, `<html>`,
///   `<iframe>`, `<meta>`, `<param>`, `<script>`, `<style>`, `<title>`
#[derive(Clone)]
pub struct OnClick {
    inner: PointerEvent,
}

impl Debug for OnClick {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        f.write_str("OnClickEvent")
    }
}

impl From<Event> for OnClick {
    fn from(e: Event) -> Self {
        Self { inner: e.unchecked_into() }
    }
}

impl OnClick {
    /// Getter for the `pointerId` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerId)
    #[inline]
    pub fn pointer_id(&self) -> i32 {
        self.inner.pointer_id()
    }
    /// Getter for the `width` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/width)
    #[inline]
    pub fn width(&self) -> i32 {
        self.inner.width()
    }
    /// Getter for the `height` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/height)
    #[inline]
    pub fn height(&self) -> i32 {
        self.inner.height()
    }
    /// Getter for the `pressure` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pressure)
    #[inline]
    pub fn pressure(&self) -> f32 {
        self.inner.pressure()
    }
    /// Getter for the `tangentialPressure` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tangentialPressure)
    #[inline]
    pub fn tangential_pressure(&self) -> f32 {
        self.inner.tangential_pressure()
    }
    /// Getter for the `tiltX` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltX)
    #[inline]
    pub fn tilt_x(&self) -> i32 {
        self.inner.tilt_x()
    }
    /// Getter for the `tiltY` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/tiltY)
    #[inline]
    pub fn tilt_y(&self) -> i32 {
        self.inner.tilt_y()
    }
    /// Getter for the `twist` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/twist)
    #[inline]
    pub fn twist(&self) -> i32 {
        self.inner.twist()
    }
    /// Getter for the `pointerType` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/pointerType)
    #[inline]
    pub fn pointer_type(&self) -> String {
        self.inner.pointer_type()
    }
    /// Getter for the `isPrimary` field of this object.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/isPrimary)
    #[inline]
    pub fn is_primary(&self) -> bool {
        self.inner.is_primary()
    }
    /// The `getCoalescedEvents()` method.
    ///
    /// [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent/getCoalescedEvents)
    #[inline]
    pub fn get_coalesced_events(&self) -> Array {
        self.inner.get_coalesced_events()
    }
}