fix desktop events
This commit is contained in:
1 parent
bd387d601c
commit
8ba1c05a93
12 files changed
+507
-217
No files matched your search
@@ -1,5 +1,6 @@
|
||||
use crate::geometry::{ClientPoint, Coordinates, ElementPoint, PagePoint, ScreenPoint};
|
||||
use crate::input_data::{MouseButton, MouseButtonSet};
|
||||
use crate::prelude::PointInteraction;
|
||||
|
||||
use dioxus_core::Event;
|
||||
use keyboard_types::Modifiers;
|
||||
@@ -43,60 +44,47 @@ impl PartialEq for DragData {
|
||||
}
|
||||
|
||||
impl DragData {
|
||||
/// The event's coordinates relative to the application's viewport (as opposed to the coordinate within the page).
|
||||
///
|
||||
/// For example, clicking in the top left corner of the viewport will always result in a mouse event with client coordinates (0., 0.), regardless of whether the page is scrolled horizontally.
|
||||
pub fn client_coordinates(&self) -> ClientPoint {
|
||||
self.inner.client_coordinates()
|
||||
}
|
||||
|
||||
/// The event's coordinates relative to the padding edge of the target element
|
||||
///
|
||||
/// For example, clicking in the top left corner of an element will result in element coordinates (0., 0.)
|
||||
pub fn element_coordinates(&self) -> ElementPoint {
|
||||
self.inner.element_coordinates()
|
||||
}
|
||||
|
||||
/// The event's coordinates relative to the entire document. This includes any portion of the document not currently visible.
|
||||
///
|
||||
/// For example, if the page is scrolled 200 pixels to the right and 300 pixels down, clicking in the top left corner of the viewport would result in page coordinates (200., 300.)
|
||||
pub fn page_coordinates(&self) -> PagePoint {
|
||||
self.inner.page_coordinates()
|
||||
}
|
||||
|
||||
/// The event's coordinates relative to the entire screen. This takes into account the window's offset.
|
||||
pub fn screen_coordinates(&self) -> ScreenPoint {
|
||||
self.inner.screen_coordinates()
|
||||
}
|
||||
|
||||
pub fn coordinates(&self) -> Coordinates {
|
||||
self.inner.coordinates()
|
||||
}
|
||||
|
||||
/// The set of modifier keys which were pressed when the event occurred
|
||||
pub fn modifiers(&self) -> Modifiers {
|
||||
self.inner.modifiers()
|
||||
}
|
||||
|
||||
/// The set of mouse buttons which were held when the event occurred.
|
||||
pub fn held_buttons(&self) -> MouseButtonSet {
|
||||
self.inner.held_buttons()
|
||||
}
|
||||
|
||||
/// The mouse button that triggered the event
|
||||
///
|
||||
// todo the following is kind of bad; should we just return None when the trigger_button is unreliable (and frankly irrelevant)? i guess we would need the event_type here
|
||||
/// This is only guaranteed to indicate which button was pressed during events caused by pressing or releasing a button. As such, it is not reliable for events such as mouseenter, mouseleave, mouseover, mouseout, or mousemove. For example, a value of MouseButton::Primary may also indicate that no button was pressed.
|
||||
pub fn trigger_button(&self) -> Option<MouseButton> {
|
||||
self.inner.trigger_button()
|
||||
}
|
||||
|
||||
/// Downcast this event data to a specific type
|
||||
pub fn downcast<T: 'static>(&self) -> Option<&T> {
|
||||
self.inner.as_any().downcast_ref::<T>()
|
||||
}
|
||||
}
|
||||
|
||||
impl PointInteraction for DragData {
|
||||
fn client_coordinates(&self) -> ClientPoint {
|
||||
self.inner.client_coordinates()
|
||||
}
|
||||
|
||||
fn element_coordinates(&self) -> ElementPoint {
|
||||
self.inner.element_coordinates()
|
||||
}
|
||||
|
||||
fn page_coordinates(&self) -> PagePoint {
|
||||
self.inner.page_coordinates()
|
||||
}
|
||||
|
||||
fn screen_coordinates(&self) -> ScreenPoint {
|
||||
self.inner.screen_coordinates()
|
||||
}
|
||||
|
||||
fn coordinates(&self) -> Coordinates {
|
||||
self.inner.coordinates()
|
||||
}
|
||||
|
||||
fn modifiers(&self) -> Modifiers {
|
||||
self.inner.modifiers()
|
||||
}
|
||||
|
||||
fn held_buttons(&self) -> MouseButtonSet {
|
||||
self.inner.held_buttons()
|
||||
}
|
||||
|
||||
// todo the following is kind of bad; should we just return None when the trigger_button is unreliable (and frankly irrelevant)? i guess we would need the event_type here
|
||||
fn trigger_button(&self) -> Option<MouseButton> {
|
||||
self.inner.trigger_button()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
/// A serialized version of DragData
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)]
|
||||
@@ -108,15 +96,7 @@ pub struct SerializedDragData {
|
||||
impl From<&DragData> for SerializedDragData {
|
||||
fn from(data: &DragData) -> Self {
|
||||
Self {
|
||||
mouse: crate::point_interaction::SerializedPointInteraction {
|
||||
client_coordinates: data.client_coordinates(),
|
||||
element_coordinates: data.element_coordinates(),
|
||||
page_coordinates: data.page_coordinates(),
|
||||
screen_coordinates: data.screen_coordinates(),
|
||||
modifiers: data.modifiers(),
|
||||
held_buttons: data.held_buttons(),
|
||||
trigger_button: data.trigger_button(),
|
||||
},
|
||||
mouse: crate::point_interaction::SerializedPointInteraction::from(data),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,30 +81,46 @@ impl KeyboardData {
|
||||
/// A serialized version of KeyboardData
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)]
|
||||
pub struct SerializedKeyboardData {
|
||||
auto_repeating: bool,
|
||||
char_code: u32,
|
||||
key: String,
|
||||
key_code: KeyCode,
|
||||
#[serde(deserialize_with = "resilient_deserialize_code")]
|
||||
code: Code,
|
||||
key: Key,
|
||||
location: Location,
|
||||
modifiers: Modifiers,
|
||||
alt_key: bool,
|
||||
ctrl_key: bool,
|
||||
meta_key: bool,
|
||||
shift_key: bool,
|
||||
location: usize,
|
||||
repeat: bool,
|
||||
which: usize,
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl SerializedKeyboardData {
|
||||
/// Create a new SerializedKeyboardData
|
||||
pub fn new(
|
||||
auto_repeating: bool,
|
||||
code: Code,
|
||||
key: Key,
|
||||
code: Code,
|
||||
location: Location,
|
||||
is_auto_repeating: bool,
|
||||
modifiers: Modifiers,
|
||||
) -> Self {
|
||||
Self {
|
||||
auto_repeating,
|
||||
char_code: key.legacy_charcode(),
|
||||
key: key.to_string(),
|
||||
key_code: KeyCode::from_raw_code(
|
||||
std::convert::TryInto::try_into(key.legacy_keycode())
|
||||
.expect("could not convert keycode to u8"),
|
||||
),
|
||||
code,
|
||||
key,
|
||||
location,
|
||||
modifiers,
|
||||
alt_key: modifiers.contains(Modifiers::ALT),
|
||||
ctrl_key: modifiers.contains(Modifiers::CONTROL),
|
||||
meta_key: modifiers.contains(Modifiers::META),
|
||||
shift_key: modifiers.contains(Modifiers::SHIFT),
|
||||
location: crate::input_data::encode_key_location(location),
|
||||
repeat: is_auto_repeating,
|
||||
which: std::convert::TryInto::try_into(key.legacy_charcode())
|
||||
.expect("could not convert charcode to usize"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,20 +128,20 @@ impl SerializedKeyboardData {
|
||||
#[cfg(feature = "serialize")]
|
||||
impl From<&KeyboardData> for SerializedKeyboardData {
|
||||
fn from(data: &KeyboardData) -> Self {
|
||||
Self {
|
||||
auto_repeating: data.is_auto_repeating(),
|
||||
code: data.code(),
|
||||
key: data.key(),
|
||||
location: data.location(),
|
||||
modifiers: data.modifiers(),
|
||||
}
|
||||
Self::new(
|
||||
data.key(),
|
||||
data.code(),
|
||||
data.location(),
|
||||
data.is_auto_repeating(),
|
||||
data.modifiers(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl HasKeyboardData for SerializedKeyboardData {
|
||||
fn key(&self) -> Key {
|
||||
self.key.clone()
|
||||
std::str::FromStr::from_str(&self.key).unwrap_or(Key::Unidentified)
|
||||
}
|
||||
|
||||
fn code(&self) -> Code {
|
||||
@@ -133,15 +149,30 @@ impl HasKeyboardData for SerializedKeyboardData {
|
||||
}
|
||||
|
||||
fn modifiers(&self) -> Modifiers {
|
||||
self.modifiers
|
||||
let mut modifiers = Modifiers::empty();
|
||||
|
||||
if self.alt_key {
|
||||
modifiers.insert(Modifiers::ALT);
|
||||
}
|
||||
if self.ctrl_key {
|
||||
modifiers.insert(Modifiers::CONTROL);
|
||||
}
|
||||
if self.meta_key {
|
||||
modifiers.insert(Modifiers::META);
|
||||
}
|
||||
if self.shift_key {
|
||||
modifiers.insert(Modifiers::SHIFT);
|
||||
}
|
||||
|
||||
modifiers
|
||||
}
|
||||
|
||||
fn location(&self) -> Location {
|
||||
self.location
|
||||
crate::input_data::decode_key_location(self.location)
|
||||
}
|
||||
|
||||
fn is_auto_repeating(&self) -> bool {
|
||||
self.auto_repeating
|
||||
self.repeat
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
|
||||
@@ -191,23 +191,17 @@ pub struct SerializedMouseData {
|
||||
impl SerializedMouseData {
|
||||
/// Create a new instance of SerializedMouseData
|
||||
pub fn new(
|
||||
client_coordinates: ClientPoint,
|
||||
element_coordinates: ElementPoint,
|
||||
page_coordinates: PagePoint,
|
||||
screen_coordinates: ScreenPoint,
|
||||
modifiers: Modifiers,
|
||||
held_buttons: MouseButtonSet,
|
||||
trigger_button: Option<MouseButton>,
|
||||
held_buttons: MouseButtonSet,
|
||||
coordinates: Coordinates,
|
||||
modifiers: Modifiers,
|
||||
) -> Self {
|
||||
Self {
|
||||
point_data: crate::point_interaction::SerializedPointInteraction::new(
|
||||
client_coordinates,
|
||||
element_coordinates,
|
||||
page_coordinates,
|
||||
screen_coordinates,
|
||||
modifiers,
|
||||
held_buttons,
|
||||
trigger_button,
|
||||
held_buttons,
|
||||
coordinates,
|
||||
modifiers,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,30 +46,42 @@ impl WheelData {
|
||||
/// A serialized version of WheelData
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone)]
|
||||
pub struct SerializedWheelData {
|
||||
delta: WheelDelta,
|
||||
pub delta_mode: u32,
|
||||
pub delta_x: f64,
|
||||
pub delta_y: f64,
|
||||
pub delta_z: f64,
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl SerializedWheelData {
|
||||
/// Create a new SerializedWheelData
|
||||
pub fn new(delta: WheelDelta) -> Self {
|
||||
Self { delta }
|
||||
let delta_mode = match delta {
|
||||
WheelDelta::Pixels(_) => 0,
|
||||
WheelDelta::Lines(_) => 1,
|
||||
WheelDelta::Pages(_) => 2,
|
||||
};
|
||||
let delta_raw = delta.strip_units();
|
||||
Self {
|
||||
delta_mode,
|
||||
delta_x: delta_raw.x,
|
||||
delta_y: delta_raw.y,
|
||||
delta_z: delta_raw.z,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl From<&WheelData> for SerializedWheelData {
|
||||
fn from(data: &WheelData) -> Self {
|
||||
Self {
|
||||
delta: data.inner.delta(),
|
||||
}
|
||||
Self::new(data.delta())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl HasWheelData for SerializedWheelData {
|
||||
fn delta(&self) -> WheelDelta {
|
||||
self.delta
|
||||
WheelDelta::from_web_attributes(self.delta_mode, self.delta_x, self.delta_y, self.delta_z)
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
|
||||
@@ -41,35 +41,98 @@ pub trait PointInteraction: std::any::Any {
|
||||
#[cfg(feature = "serialize")]
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Clone, Default)]
|
||||
pub(crate) struct SerializedPointInteraction {
|
||||
pub(crate) client_coordinates: ClientPoint,
|
||||
pub(crate) element_coordinates: ElementPoint,
|
||||
pub(crate) page_coordinates: PagePoint,
|
||||
pub(crate) screen_coordinates: ScreenPoint,
|
||||
pub(crate) modifiers: Modifiers,
|
||||
pub(crate) held_buttons: MouseButtonSet,
|
||||
pub(crate) trigger_button: Option<MouseButton>,
|
||||
pub alt_key: bool,
|
||||
|
||||
/// The button number that was pressed (if applicable) when the mouse event was fired.
|
||||
pub button: i16,
|
||||
|
||||
/// Indicates which buttons are pressed on the mouse (or other input device) when a mouse event is triggered.
|
||||
///
|
||||
/// Each button that can be pressed is represented by a given number (see below). If more than one button is pressed, the button values are added together to produce a new number. For example, if the secondary (2) and auxiliary (4) buttons are pressed simultaneously, the value is 6 (i.e., 2 + 4).
|
||||
///
|
||||
/// - 1: Primary button (usually the left button)
|
||||
/// - 2: Secondary button (usually the right button)
|
||||
/// - 4: Auxiliary button (usually the mouse wheel button or middle button)
|
||||
/// - 8: 4th button (typically the "Browser Back" button)
|
||||
/// - 16 : 5th button (typically the "Browser Forward" button)
|
||||
pub buttons: u16,
|
||||
|
||||
/// The horizontal coordinate within the application's viewport at which the event occurred (as opposed to the coordinate within the page).
|
||||
///
|
||||
/// For example, clicking on the left edge of the viewport will always result in a mouse event with a clientX value of 0, regardless of whether the page is scrolled horizontally.
|
||||
pub client_x: i32,
|
||||
|
||||
/// The vertical coordinate within the application's viewport at which the event occurred (as opposed to the coordinate within the page).
|
||||
///
|
||||
/// For example, clicking on the top edge of the viewport will always result in a mouse event with a clientY value of 0, regardless of whether the page is scrolled vertically.
|
||||
pub client_y: i32,
|
||||
|
||||
/// True if the control key was down when the mouse event was fired.
|
||||
pub ctrl_key: bool,
|
||||
|
||||
/// True if the meta key was down when the mouse event was fired.
|
||||
pub meta_key: bool,
|
||||
|
||||
/// The offset in the X coordinate of the mouse pointer between that event and the padding edge of the target node.
|
||||
pub offset_x: i32,
|
||||
|
||||
/// The offset in the Y coordinate of the mouse pointer between that event and the padding edge of the target node.
|
||||
pub offset_y: i32,
|
||||
|
||||
/// The X (horizontal) coordinate (in pixels) of the mouse, relative to the left edge of the entire document. This includes any portion of the document not currently visible.
|
||||
///
|
||||
/// Being based on the edge of the document as it is, this property takes into account any horizontal scrolling of the page. For example, if the page is scrolled such that 200 pixels of the left side of the document are scrolled out of view, and the mouse is clicked 100 pixels inward from the left edge of the view, the value returned by pageX will be 300.
|
||||
pub page_x: i32,
|
||||
|
||||
/// The Y (vertical) coordinate in pixels of the event relative to the whole document.
|
||||
///
|
||||
/// See `page_x`.
|
||||
pub page_y: i32,
|
||||
|
||||
/// The X coordinate of the mouse pointer in global (screen) coordinates.
|
||||
pub screen_x: i32,
|
||||
|
||||
/// The Y coordinate of the mouse pointer in global (screen) coordinates.
|
||||
pub screen_y: i32,
|
||||
|
||||
/// True if the shift key was down when the mouse event was fired.
|
||||
pub shift_key: bool,
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl SerializedPointInteraction {
|
||||
/// Create a new serialized point interaction.
|
||||
pub fn new(
|
||||
client_coordinates: ClientPoint,
|
||||
element_coordinates: ElementPoint,
|
||||
page_coordinates: PagePoint,
|
||||
screen_coordinates: ScreenPoint,
|
||||
modifiers: Modifiers,
|
||||
held_buttons: MouseButtonSet,
|
||||
trigger_button: Option<MouseButton>,
|
||||
held_buttons: MouseButtonSet,
|
||||
coordinates: Coordinates,
|
||||
modifiers: Modifiers,
|
||||
) -> Self {
|
||||
let alt_key = modifiers.contains(Modifiers::ALT);
|
||||
let ctrl_key = modifiers.contains(Modifiers::CONTROL);
|
||||
let meta_key = modifiers.contains(Modifiers::META);
|
||||
let shift_key = modifiers.contains(Modifiers::SHIFT);
|
||||
|
||||
let [client_x, client_y]: [i32; 2] = coordinates.client().cast().into();
|
||||
let [offset_x, offset_y]: [i32; 2] = coordinates.element().cast().into();
|
||||
let [page_x, page_y]: [i32; 2] = coordinates.page().cast().into();
|
||||
let [screen_x, screen_y]: [i32; 2] = coordinates.screen().cast().into();
|
||||
Self {
|
||||
client_coordinates,
|
||||
element_coordinates,
|
||||
page_coordinates,
|
||||
screen_coordinates,
|
||||
modifiers,
|
||||
held_buttons,
|
||||
trigger_button,
|
||||
button: trigger_button
|
||||
.map_or(MouseButton::default(), |b| b)
|
||||
.into_web_code(),
|
||||
buttons: crate::input_data::encode_mouse_button_set(held_buttons),
|
||||
meta_key,
|
||||
ctrl_key,
|
||||
shift_key,
|
||||
alt_key,
|
||||
client_x,
|
||||
client_y,
|
||||
screen_x,
|
||||
screen_y,
|
||||
offset_x,
|
||||
offset_y,
|
||||
page_x,
|
||||
page_y,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,54 +140,56 @@ impl SerializedPointInteraction {
|
||||
#[cfg(feature = "serialize")]
|
||||
impl<E: PointInteraction> From<&E> for SerializedPointInteraction {
|
||||
fn from(data: &E) -> Self {
|
||||
Self {
|
||||
client_coordinates: data.client_coordinates(),
|
||||
element_coordinates: data.element_coordinates(),
|
||||
page_coordinates: data.page_coordinates(),
|
||||
screen_coordinates: data.screen_coordinates(),
|
||||
modifiers: data.modifiers(),
|
||||
held_buttons: data.held_buttons(),
|
||||
trigger_button: data.trigger_button(),
|
||||
}
|
||||
let trigger_button = data.trigger_button();
|
||||
let held_buttons = data.held_buttons();
|
||||
let coordinates = data.coordinates();
|
||||
let modifiers = data.modifiers();
|
||||
Self::new(trigger_button, held_buttons, coordinates, modifiers)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl PointInteraction for SerializedPointInteraction {
|
||||
fn client_coordinates(&self) -> ClientPoint {
|
||||
self.client_coordinates
|
||||
}
|
||||
|
||||
fn element_coordinates(&self) -> ElementPoint {
|
||||
self.element_coordinates
|
||||
}
|
||||
|
||||
fn page_coordinates(&self) -> PagePoint {
|
||||
self.page_coordinates
|
||||
ClientPoint::new(self.client_x.into(), self.client_y.into())
|
||||
}
|
||||
|
||||
fn screen_coordinates(&self) -> ScreenPoint {
|
||||
self.screen_coordinates
|
||||
ScreenPoint::new(self.screen_x.into(), self.screen_y.into())
|
||||
}
|
||||
|
||||
fn coordinates(&self) -> Coordinates {
|
||||
Coordinates::new(
|
||||
self.screen_coordinates(),
|
||||
self.client_coordinates(),
|
||||
self.element_coordinates(),
|
||||
self.page_coordinates(),
|
||||
)
|
||||
fn element_coordinates(&self) -> ElementPoint {
|
||||
ElementPoint::new(self.offset_x.into(), self.offset_y.into())
|
||||
}
|
||||
|
||||
fn page_coordinates(&self) -> PagePoint {
|
||||
PagePoint::new(self.page_x.into(), self.page_y.into())
|
||||
}
|
||||
|
||||
fn modifiers(&self) -> Modifiers {
|
||||
self.modifiers
|
||||
let mut modifiers = Modifiers::empty();
|
||||
|
||||
if self.alt_key {
|
||||
modifiers.insert(Modifiers::ALT);
|
||||
}
|
||||
if self.ctrl_key {
|
||||
modifiers.insert(Modifiers::CONTROL);
|
||||
}
|
||||
if self.meta_key {
|
||||
modifiers.insert(Modifiers::META);
|
||||
}
|
||||
if self.shift_key {
|
||||
modifiers.insert(Modifiers::SHIFT);
|
||||
}
|
||||
|
||||
modifiers
|
||||
}
|
||||
|
||||
fn held_buttons(&self) -> MouseButtonSet {
|
||||
self.held_buttons
|
||||
crate::input_data::decode_mouse_button_set(self.buttons)
|
||||
}
|
||||
|
||||
fn trigger_button(&self) -> Option<MouseButton> {
|
||||
self.trigger_button
|
||||
Some(MouseButton::from_web_code(self.button))
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ use crate::events::*;
|
||||
use dioxus_core::ElementId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
#[derive(Serialize, Debug, PartialEq)]
|
||||
pub struct HtmlEvent {
|
||||
pub element: ElementId,
|
||||
@@ -12,6 +13,7 @@ pub struct HtmlEvent {
|
||||
pub data: EventData,
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl<'de> Deserialize<'de> for HtmlEvent {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
@@ -41,6 +43,7 @@ impl<'de> Deserialize<'de> for HtmlEvent {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
fn fun_name(
|
||||
name: &str,
|
||||
data: serde_value::Value,
|
||||
@@ -130,6 +133,7 @@ fn fun_name(
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
impl HtmlEvent {
|
||||
pub fn bubbles(&self) -> bool {
|
||||
event_bubbles(&self.name)
|
||||
@@ -140,47 +144,79 @@ impl HtmlEvent {
|
||||
#[serde(untagged)]
|
||||
#[non_exhaustive]
|
||||
pub enum EventData {
|
||||
Mouse(MouseData),
|
||||
Clipboard(ClipboardData),
|
||||
Composition(CompositionData),
|
||||
Keyboard(KeyboardData),
|
||||
Focus(FocusData),
|
||||
Form(FormData),
|
||||
Drag(DragData),
|
||||
Pointer(PointerData),
|
||||
Selection(SelectionData),
|
||||
Touch(TouchData),
|
||||
Scroll(ScrollData),
|
||||
Wheel(WheelData),
|
||||
Media(MediaData),
|
||||
Animation(AnimationData),
|
||||
Transition(TransitionData),
|
||||
Toggle(ToggleData),
|
||||
Image(ImageData),
|
||||
Mouse(SerializedMouseData),
|
||||
Clipboard(SerializedClipboardData),
|
||||
Composition(SerializedCompositionData),
|
||||
Keyboard(SerializedKeyboardData),
|
||||
Focus(SerializedFocusData),
|
||||
Form(SerializedFormData),
|
||||
Drag(SerializedDragData),
|
||||
Pointer(SerializedPointerData),
|
||||
Selection(SerializedSelectionData),
|
||||
Touch(SerializedTouchData),
|
||||
Scroll(SerializedScrollData),
|
||||
Wheel(SerializedWheelData),
|
||||
Media(SerializedMediaData),
|
||||
Animation(SerializedAnimationData),
|
||||
Transition(SerializedTransitionData),
|
||||
Toggle(SerializedToggleData),
|
||||
Image(SerializedImageData),
|
||||
Mounted,
|
||||
}
|
||||
|
||||
impl EventData {
|
||||
pub fn into_any(self) -> Rc<dyn Any> {
|
||||
match self {
|
||||
EventData::Mouse(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Clipboard(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Composition(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Keyboard(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Focus(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Form(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Drag(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Pointer(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Selection(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Touch(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Scroll(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Wheel(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Media(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Animation(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Transition(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Toggle(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Image(data) => Rc::new(data) as Rc<dyn Any>,
|
||||
EventData::Mounted => Rc::new(MountedData::new(())) as Rc<dyn Any>,
|
||||
EventData::Mouse(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Clipboard(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Composition(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Keyboard(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Focus(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Form(data) => Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>,
|
||||
EventData::Drag(data) => Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>,
|
||||
EventData::Pointer(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Selection(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Touch(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Scroll(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Wheel(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Media(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Animation(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Transition(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Toggle(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Image(data) => {
|
||||
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
|
||||
}
|
||||
EventData::Mounted => {
|
||||
Rc::new(PlatformEventData::new(Box::new(MountedData::new(())))) as Rc<dyn Any>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user