Generalize Query system for use in use_eval and node querys
This commit is contained in:
1 parent
7636c046fa
commit
fa9f0d0f6c
8 files changed
+186
-282
No files matched your search
@@ -79,13 +79,16 @@ impl MountedData {
|
||||
}
|
||||
|
||||
/// Scroll to make the element visible
|
||||
pub async fn scroll_to(&self, behavior: ScrollBehavior) -> MountedResult<()> {
|
||||
self.inner.scroll_to(behavior).await
|
||||
pub fn scroll_to(
|
||||
&self,
|
||||
behavior: ScrollBehavior,
|
||||
) -> Pin<Box<dyn Future<Output = MountedResult<()>>>> {
|
||||
self.inner.scroll_to(behavior)
|
||||
}
|
||||
|
||||
/// Set the focus on the element
|
||||
pub async fn set_focus(&self, focus: bool) -> MountedResult<()> {
|
||||
self.inner.set_focus(focus).await
|
||||
pub fn set_focus(&self, focus: bool) -> Pin<Box<dyn Future<Output = MountedResult<()>>>> {
|
||||
self.inner.set_focus(focus)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ use std::{any::Any, rc::Rc};
|
||||
|
||||
use crate::events::*;
|
||||
use dioxus_core::ElementId;
|
||||
use euclid::Rect;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Debug, Clone, PartialEq)]
|
||||
@@ -221,49 +220,3 @@ fn test_back_and_forth() {
|
||||
|
||||
assert_eq!(data, p);
|
||||
}
|
||||
|
||||
/// Message to update a node to support MountedData
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct NodeUpdate {
|
||||
/// The id of the node to update
|
||||
pub id: u32,
|
||||
/// The id of the request
|
||||
pub request_id: usize,
|
||||
/// The data to update the node with
|
||||
pub data: NodeUpdateData,
|
||||
}
|
||||
|
||||
/// Message to update a node to support MountedData
|
||||
#[cfg_attr(
|
||||
feature = "serialize",
|
||||
derive(serde::Serialize, serde::Deserialize),
|
||||
serde(tag = "type")
|
||||
)]
|
||||
pub enum NodeUpdateData {
|
||||
SetFocus { focus: bool },
|
||||
GetClientRect {},
|
||||
ScrollTo { behavior: ScrollBehavior },
|
||||
}
|
||||
|
||||
/// The result of a element query
|
||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct MountedReturn {
|
||||
/// A unique id for the query
|
||||
pub id: usize,
|
||||
/// The result of the query
|
||||
pub data: Option<MountedReturnData>,
|
||||
}
|
||||
|
||||
/// The data of a element query
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(
|
||||
feature = "serialize",
|
||||
derive(serde::Serialize, serde::Deserialize),
|
||||
serde(tag = "type")
|
||||
)]
|
||||
pub enum MountedReturnData {
|
||||
SetFocus(()),
|
||||
GetClientRect(Rect<f64, f64>),
|
||||
ScrollTo(()),
|
||||
}
|
||||
Reference in new issue
Block a user