fix the ondouble click desktop test

This commit is contained in:
Evan Almloff 2024-01-06 15:55:43 -06:00
parent 8f70509bc3
commit 53422ae199
2 changed files with 11 additions and 17 deletions

View file

@ -6,7 +6,7 @@ macro_rules! impl_event {
$data:ty;
$(
$( #[$attr:meta] )*
$name:ident
$name:ident $(: $js_name:literal)?
)*
) => {
$(
@ -14,7 +14,7 @@ macro_rules! impl_event {
#[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::new(
stringify!($name),
impl_event!(@name $name $($js_name)?),
_cx.listener(move |e: ::dioxus_core::Event<crate::PlatformEventData>| {
_f(e.map(|e|e.into())).spawn(_cx);
}),
@ -24,6 +24,13 @@ macro_rules! impl_event {
}
)*
};
(@name $name:ident $js_name:literal) => {
$js_name
};
(@name $name:ident) => {
stringify!($name)
};
}
static EVENT_CONVERTER: RwLock<Option<Box<dyn HtmlEventConverter>>> = RwLock::new(None);

View file

@ -78,6 +78,8 @@ impl_event! {
#[deprecated(since = "0.5.0", note = "use ondoubleclick instead")]
ondblclick
ondoubleclick: "ondblclick"
/// onmousedown
onmousedown
@ -102,21 +104,6 @@ impl_event! {
onmouseup
}
/// ondoubleclick
#[inline]
pub fn ondoubleclick<'a, E: crate::EventReturn<T>, T>(
_cx: &'a ::dioxus_core::ScopeState,
mut _f: impl FnMut(::dioxus_core::Event<MouseData>) -> E + 'a,
) -> ::dioxus_core::Attribute<'a> {
::dioxus_core::Attribute::new(
"ondblclick",
_cx.listener(move |e: ::dioxus_core::Event<MouseData>| {
_f(e).spawn(_cx);
}),
None,
false,
)
}
impl MouseData {
/// Create a new instance of MouseData