feat: add proper event type
This commit is contained in:
1 parent
aa71c111cd
commit
50faa7dd08
22 files changed
+273
-47
No files matched your search
@@ -3,7 +3,7 @@ use dioxus_core::Event;
|
||||
pub type AnimationEvent = Event<AnimationData>;
|
||||
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct AnimationData {
|
||||
pub animation_name: String,
|
||||
pub pseudo_element: String,
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type ClipboardEvent = Event<ClipboardData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ClipboardData {
|
||||
// DOMDataTransfer clipboardData
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type CompositionEvent = Event<CompositionData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct CompositionData {
|
||||
pub data: String,
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::any::Any;
|
||||
|
||||
use dioxus_core::Event;
|
||||
|
||||
use crate::MouseData;
|
||||
@@ -10,12 +8,11 @@ pub type DragEvent = Event<DragData>;
|
||||
/// placing a pointer device (such as a mouse) on the touch surface and then dragging the pointer to a new location
|
||||
/// (such as another DOM element). Applications are free to interpret a drag and drop interaction in an
|
||||
/// application-specific way.
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct DragData {
|
||||
/// Inherit mouse data
|
||||
pub mouse: MouseData,
|
||||
|
||||
/// And then add the rest of the drag data
|
||||
pub data: Box<dyn Any>,
|
||||
}
|
||||
|
||||
impl_event! {
|
||||
|
||||
@@ -3,7 +3,7 @@ use dioxus_core::Event;
|
||||
pub type FocusEvent = Event<FocusData>;
|
||||
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct FocusData {/* DOMEventInner: Send + SyncTarget relatedTarget */}
|
||||
|
||||
impl_event! [
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{collections::HashMap, fmt::Debug, sync::Arc};
|
||||
use std::{collections::HashMap, fmt::Debug};
|
||||
|
||||
use dioxus_core::Event;
|
||||
|
||||
@@ -6,14 +6,13 @@ pub type FormEvent = Event<FormData>;
|
||||
|
||||
/* DOMEvent: Send + SyncTarget relatedTarget */
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq, Default)]
|
||||
pub struct FormData {
|
||||
pub value: String,
|
||||
|
||||
pub values: HashMap<String, String>,
|
||||
|
||||
#[cfg_attr(feature = "serialize", serde(skip))]
|
||||
pub files: Option<Arc<dyn FileEngine>>,
|
||||
// #[cfg_attr(feature = "serialize", serde(skip))]
|
||||
// pub files: Option<Arc<dyn FileEngine>>,
|
||||
}
|
||||
|
||||
impl Debug for FormData {
|
||||
@@ -25,17 +24,17 @@ impl Debug for FormData {
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait(?Send)]
|
||||
pub trait FileEngine {
|
||||
// get a list of file names
|
||||
fn files(&self) -> Vec<String>;
|
||||
// #[async_trait::async_trait(?Send)]
|
||||
// pub trait FileEngine {
|
||||
// // get a list of file names
|
||||
// fn files(&self) -> Vec<String>;
|
||||
|
||||
// read a file to bytes
|
||||
async fn read_file(&self, file: &str) -> Option<Vec<u8>>;
|
||||
// // read a file to bytes
|
||||
// async fn read_file(&self, file: &str) -> Option<Vec<u8>>;
|
||||
|
||||
// read a file to string
|
||||
async fn read_file_to_string(&self, file: &str) -> Option<String>;
|
||||
}
|
||||
// // read a file to string
|
||||
// async fn read_file_to_string(&self, file: &str) -> Option<String>;
|
||||
// }
|
||||
|
||||
impl_event! {
|
||||
FormData;
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type ImageEvent = Event<ImageData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ImageData {
|
||||
pub load_error: bool,
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::str::FromStr;
|
||||
|
||||
pub type KeyboardEvent = Event<KeyboardData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct KeyboardData {
|
||||
#[deprecated(
|
||||
since = "0.3.0",
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type MediaEvent = Event<MediaData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct MediaData {}
|
||||
|
||||
impl_event! [
|
||||
|
||||
@@ -10,7 +10,7 @@ pub type MouseEvent = Event<MouseData>;
|
||||
|
||||
/// A synthetic event that wraps a web-style [`MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent)
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Clone, Default)]
|
||||
#[derive(Clone, Default, PartialEq)]
|
||||
/// Data associated with a mouse event
|
||||
///
|
||||
/// Do not use the deprecated fields; they may change or become private in the future.
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type PointerEvent = Event<PointerData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct PointerData {
|
||||
// Mouse only
|
||||
pub alt_key: bool,
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type ScrollEvent = Event<ScrollData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ScrollData {}
|
||||
|
||||
impl_event! {
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type SelectionEvent = Event<SelectionData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SelectionData {}
|
||||
|
||||
impl_event! [
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type ToggleEvent = Event<ToggleData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ToggleData {}
|
||||
|
||||
impl_event! {
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type TouchEvent = Event<TouchData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TouchData {
|
||||
pub alt_key: bool,
|
||||
pub ctrl_key: bool,
|
||||
|
||||
@@ -2,7 +2,7 @@ use dioxus_core::Event;
|
||||
|
||||
pub type TransitionEvent = Event<TransitionData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct TransitionData {
|
||||
pub property_name: String,
|
||||
pub pseudo_element: String,
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::geometry::{LinesVector, PagesVector, PixelsVector, WheelDelta};
|
||||
|
||||
pub type WheelEvent = Event<WheelData>;
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, PartialEq, Default)]
|
||||
pub struct WheelData {
|
||||
#[deprecated(since = "0.3.0", note = "use delta() instead")]
|
||||
pub delta_mode: u32,
|
||||
|
||||
Reference in new issue
Block a user