wip: web stuff

This commit is contained in:
Jonathan Kelley 2021-08-31 12:28:57 -04:00
parent 5cbdc571e3
commit acad9ca622
2 changed files with 6 additions and 6 deletions

View file

@ -8,7 +8,7 @@ use dioxus_core::{
on::{MouseEvent, MouseEventInner}, on::{MouseEvent, MouseEventInner},
SyntheticEvent, SyntheticEvent,
}, },
ElementId, EventPriority, EventTrigger, ScopeId, ElementId, EventPriority, ScopeId, UiEvent,
}; };
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
@ -17,14 +17,14 @@ struct ImEvent {
mounted_dom_id: u64, mounted_dom_id: u64,
scope: u64, scope: u64,
} }
pub fn trigger_from_serialized(val: serde_json::Value) -> EventTrigger { pub fn trigger_from_serialized(val: serde_json::Value) -> UiEvent {
let mut data: Vec<ImEvent> = serde_json::from_value(val).unwrap(); let mut data: Vec<ImEvent> = serde_json::from_value(val).unwrap();
let data = data.drain(..).next().unwrap(); let data = data.drain(..).next().unwrap();
let event = SyntheticEvent::MouseEvent(MouseEvent(Rc::new(WebviewMouseEvent))); let event = SyntheticEvent::MouseEvent(MouseEvent(Rc::new(WebviewMouseEvent)));
let scope = ScopeId(data.scope as usize); let scope = ScopeId(data.scope as usize);
let mounted_dom_id = Some(ElementId(data.mounted_dom_id as usize)); let mounted_dom_id = Some(ElementId(data.mounted_dom_id as usize));
EventTrigger { UiEvent {
event, event,
scope, scope,
mounted_dom_id, mounted_dom_id,

View file

@ -1,7 +1,7 @@
use std::{collections::HashMap, fmt::Debug, rc::Rc, sync::Arc}; use std::{collections::HashMap, fmt::Debug, rc::Rc, sync::Arc};
use dioxus_core::{ use dioxus_core::{
events::{on::GenericEventInner, EventTrigger, SyntheticEvent}, events::{on::GenericEventInner, SyntheticEvent, UiEvent},
mutations::NodeRefMutation, mutations::NodeRefMutation,
scheduler::SchedulerMsg, scheduler::SchedulerMsg,
DomEdit, ElementId, ScopeId, DomEdit, ElementId, ScopeId,
@ -519,7 +519,7 @@ fn virtual_event_from_websys_event(event: web_sys::Event) -> SyntheticEvent {
/// This function decodes a websys event and produces an EventTrigger /// This function decodes a websys event and produces an EventTrigger
/// With the websys implementation, we attach a unique key to the nodes /// With the websys implementation, we attach a unique key to the nodes
fn decode_trigger(event: &web_sys::Event) -> anyhow::Result<EventTrigger> { fn decode_trigger(event: &web_sys::Event) -> anyhow::Result<UiEvent> {
log::debug!("Handling event!"); log::debug!("Handling event!");
let target = event let target = event
@ -561,7 +561,7 @@ fn decode_trigger(event: &web_sys::Event) -> anyhow::Result<EventTrigger> {
let triggered_scope = gi_id; let triggered_scope = gi_id;
// let triggered_scope: ScopeId = KeyData::from_ffi(gi_id).into(); // let triggered_scope: ScopeId = KeyData::from_ffi(gi_id).into();
log::debug!("Triggered scope is {:#?}", triggered_scope); log::debug!("Triggered scope is {:#?}", triggered_scope);
Ok(EventTrigger { Ok(UiEvent {
event: virtual_event_from_websys_event(event.clone()), event: virtual_event_from_websys_event(event.clone()),
mounted_dom_id: Some(ElementId(real_id as usize)), mounted_dom_id: Some(ElementId(real_id as usize)),
scope: ScopeId(triggered_scope as usize), scope: ScopeId(triggered_scope as usize),