pub struct UiRef { /* private fields */ }
Expand description
Refence to UI
Implementations§
source§impl UiRef
impl UiRef
sourcepub async fn device_pixel_ratio(&self) -> Result<f32>
pub async fn device_pixel_ratio(&self) -> Result<f32>
sourcepub fn add_element<OptCB, CB>(
&self,
html_element: &str,
parent: &Element,
element_ready: OptCB
) -> Result<Element>where
CB: FnMut(UiRef, Element) + Send + Clone + 'static,
OptCB: Into<Option<CB>>,
pub fn add_element<OptCB, CB>( &self, html_element: &str, parent: &Element, element_ready: OptCB ) -> Result<Element>where CB: FnMut(UiRef, Element) + Send + Clone + 'static, OptCB: Into<Option<CB>>,
Create a new element
Example
fn some_function(ui: UiRef) {
ui.add_element("div", &ui.root(), |_, el: Element| el.set_html("foo"));
}
Arguments
html_element
- refer to HTML id
parent
- parent of element
element_ready
- callback called upon element is created
Return
Element created, please note that element creation may not be completed yet.
sourcepub async fn add_element_async(
&self,
html_element: &str,
parent: &Element
) -> Result<Element>
pub async fn add_element_async( &self, html_element: &str, parent: &Element ) -> Result<Element>
Create a new element
Example
async fn some_function(ui: UiRef) {
let el = ui.add_element_async("div", &ui.root()).await.unwrap();
el.set_html("foo")
}
Arguments
id
- id of element - is expexted to be unique in the application context
html_element
- refer to HTML id
parent
- parent of element
Return
Element created
sourcepub fn add_element_with_id<OptCB, CB>(
&self,
id: &str,
html_element: &str,
parent: &Element,
element_ready: OptCB
) -> Result<Element>where
CB: FnMut(UiRef, Element) + Clone + Send + 'static,
OptCB: Into<Option<CB>>,
pub fn add_element_with_id<OptCB, CB>( &self, id: &str, html_element: &str, parent: &Element, element_ready: OptCB ) -> Result<Element>where CB: FnMut(UiRef, Element) + Clone + Send + 'static, OptCB: Into<Option<CB>>,
Create a new element
See more information add_element
Arguments
id
- id of element - is expexted to be unique in the application context
html_element
- refer to HTML id
parent
- parent of element
element_ready
- callback called upon element is created
Return
Element created, please note that element creation may not be completed yet.
sourcepub async fn add_element_with_id_async(
&self,
id: &str,
html_element: &str,
parent: &Element
) -> Result<Element>
pub async fn add_element_with_id_async( &self, id: &str, html_element: &str, parent: &Element ) -> Result<Element>
Create a new element
See more information add_element
Arguments
id
- id of element - is expexted to be unique in the application context
html_element
- refer to HTML id
parent
- parent of element
Return
Element created
Trait Implementations§
source§impl Ui for UiRef
impl Ui for UiRef
source§fn root(&self) -> Element
fn root(&self) -> Element
source§fn batch_begin(&self)
fn batch_begin(&self)
source§fn set_logging(&self, logging: bool)
fn set_logging(&self, logging: bool)
source§fn resource(&self, resource_name: &str) -> Option<Box<[u8]>>
fn resource(&self, resource_name: &str) -> Option<Box<[u8]>>
source§fn add_resource<PathStr>(&self, path: PathStr) -> Result<String>where
PathStr: AsRef<Path>,
fn add_resource<PathStr>(&self, path: PathStr) -> Result<String>where PathStr: AsRef<Path>,
source§fn element(&self, id: &str) -> Element
fn element(&self, id: &str) -> Element
add_element
, see UiRef::add_element_async or UiRef::add_element_async how to create a non-exiting
element. Please note that this function always success event there is no such element as this creates a light weight
Rust side struct. You have to call some query function to get error or call some function to get an error callback. Read more