123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- macro_rules! impl_event {
- (
- $data:ty;
- $(
- $( #[$attr:meta] )*
- $name:ident
- )*
- ) => {
- $(
- $( #[$attr] )*
- #[inline]
- pub fn $name<'a, E: crate::EventReturn<T>, T>(_cx: &'a ::dioxus_core::ScopeState, mut _f: impl FnMut(::dioxus_core::Event<$data>) -> E + 'a) -> ::dioxus_core::Attribute<'a> {
- ::dioxus_core::Attribute {
- name: stringify!($name),
- value: _cx.listener(move |e: ::dioxus_core::Event<$data>| {
- _f(e).spawn(_cx);
- }),
- namespace: None,
- mounted_element: Default::default(),
- volatile: false,
- }
- }
- )*
- };
- }
- mod animation;
- mod clipboard;
- mod composition;
- mod drag;
- mod focus;
- mod form;
- mod image;
- mod keyboard;
- mod media;
- mod mouse;
- mod pointer;
- mod scroll;
- mod selection;
- mod toggle;
- mod touch;
- mod transition;
- mod wheel;
- pub use animation::*;
- pub use clipboard::*;
- pub use composition::*;
- pub use drag::*;
- pub use focus::*;
- pub use form::*;
- pub use image::*;
- pub use keyboard::*;
- pub use media::*;
- pub use mouse::*;
- pub use pointer::*;
- pub use scroll::*;
- pub use selection::*;
- pub use toggle::*;
- pub use touch::*;
- pub use transition::*;
- pub use wheel::*;
- pub fn event_bubbles(evt: &str) -> bool {
- match evt {
- "copy" => true,
- "cut" => true,
- "paste" => true,
- "compositionend" => true,
- "compositionstart" => true,
- "compositionupdate" => true,
- "keydown" => true,
- "keypress" => true,
- "keyup" => true,
- "focus" => false,
- "focusout" => true,
- "focusin" => true,
- "blur" => false,
- "change" => true,
- "input" => true,
- "invalid" => true,
- "reset" => true,
- "submit" => true,
- "click" => true,
- "contextmenu" => true,
- "doubleclick" => true,
- "dblclick" => true,
- "drag" => true,
- "dragend" => true,
- "dragenter" => false,
- "dragexit" => false,
- "dragleave" => true,
- "dragover" => true,
- "dragstart" => true,
- "drop" => true,
- "mousedown" => true,
- "mouseenter" => false,
- "mouseleave" => false,
- "mousemove" => true,
- "mouseout" => true,
- "scroll" => false,
- "mouseover" => true,
- "mouseup" => true,
- "pointerdown" => true,
- "pointermove" => true,
- "pointerup" => true,
- "pointercancel" => true,
- "gotpointercapture" => true,
- "lostpointercapture" => true,
- "pointerenter" => false,
- "pointerleave" => false,
- "pointerover" => true,
- "pointerout" => true,
- "select" => true,
- "touchcancel" => true,
- "touchend" => true,
- "touchmove" => true,
- "touchstart" => true,
- "wheel" => true,
- "abort" => false,
- "canplay" => false,
- "canplaythrough" => false,
- "durationchange" => false,
- "emptied" => false,
- "encrypted" => true,
- "ended" => false,
- "error" => false,
- "loadeddata" => false,
- "loadedmetadata" => false,
- "loadstart" => false,
- "load" => false,
- "pause" => false,
- "play" => false,
- "playing" => false,
- "progress" => false,
- "ratechange" => false,
- "seeked" => false,
- "seeking" => false,
- "stalled" => false,
- "suspend" => false,
- "timeupdate" => false,
- "volumechange" => false,
- "waiting" => false,
- "animationstart" => true,
- "animationend" => true,
- "animationiteration" => true,
- "transitionend" => true,
- "toggle" => true,
- _ => true,
- }
- }
- use std::future::Future;
- #[doc(hidden)]
- pub trait EventReturn<P>: Sized {
- fn spawn(self, _cx: &dioxus_core::ScopeState) {}
- }
- impl EventReturn<()> for () {}
- #[doc(hidden)]
- pub struct AsyncMarker;
- impl<T> EventReturn<AsyncMarker> for T
- where
- T: Future<Output = ()> + 'static,
- {
- #[inline]
- fn spawn(self, cx: &dioxus_core::ScopeState) {
- cx.spawn(self);
- }
- }
|