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

+15
View File
@@ -65,6 +65,9 @@ fn deserialize_raw(name: &str, data: &serde_json::Value) -> Result<EventData, se
}
let data = match name {
// Cancel
"cancel" => Cancel(de(data)?),
// Mouse
"click" | "contextmenu" | "dblclick" | "doubleclick" | "mousedown" | "mouseenter"
| "mouseleave" | "mousemove" | "mouseout" | "mouseover" | "mouseup" => Mouse(de(data)?),
@@ -154,6 +157,7 @@ impl HtmlEvent {
#[serde(untagged)]
#[non_exhaustive]
pub enum EventData {
Cancel(SerializedCancelData),
Mouse(SerializedMouseData),
Clipboard(SerializedClipboardData),
Composition(SerializedCompositionData),
@@ -179,6 +183,9 @@ pub enum EventData {
impl EventData {
pub fn into_any(self) -> Rc<dyn Any> {
match self {
EventData::Cancel(data) => {
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
}
EventData::Mouse(data) => {
Rc::new(PlatformEventData::new(Box::new(data))) as Rc<dyn Any>
}
@@ -291,6 +298,14 @@ impl HtmlEventConverter for SerializedHtmlEventConverter {
.into()
}
fn convert_cancel_data(&self, event: &PlatformEventData) -> CancelData {
event
.downcast::<SerializedCancelData>()
.cloned()
.unwrap()
.into()
}
fn convert_clipboard_data(&self, event: &PlatformEventData) -> ClipboardData {
event
.downcast::<SerializedClipboardData>()