Add cancel event (#4476)

* feat: add cancel event

* feat: provide cancel event

* feat: insert cancel event in web

* fix: typo

* feat: propagate implementation of cancel event

* fix merge conflicts / tests

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
Damien CORLERandJonathan Kelley authored and GitHub committed 2025-08-20 11:09:24 -07:00
1 parent f95d8e4682
commit 8d617080b1
9 files changed
+165 -5

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
use super::{Synthetic, WebEventExt};
use dioxus_html::HasCancelData;
impl HasCancelData for Synthetic<web_sys::Event> {
fn as_any(&self) -> &dyn std::any::Any {
&self.event
}
}
impl WebEventExt for dioxus_html::CancelData {
type WebEvent = web_sys::Event;
#[inline(always)]
fn try_as_web_event(&self) -> Option<Self::WebEvent> {
self.downcast::<web_sys::Event>().cloned()
}
}
+9
View File
@@ -7,6 +7,7 @@ use wasm_bindgen::JsCast;
use web_sys::{Document, Element, Event};
mod animation;
mod cancel;
mod clipboard;
mod composition;
mod drag;
@@ -60,6 +61,14 @@ impl HtmlEventConverter for WebEventConverter {
Synthetic::<web_sys::AnimationEvent>::from(downcast_event(event).raw.clone()).into()
}
#[inline(always)]
fn convert_cancel_data(
&self,
event: &dioxus_html::PlatformEventData,
) -> dioxus_html::CancelData {
Synthetic::new(downcast_event(event).raw.clone()).into()
}
#[inline(always)]
fn convert_clipboard_data(
&self,