pub struct Dom { /* private fields */ }Expand description
The DOM that contains the tree of active widgets.
Implementations§
Source§impl Dom
impl Dom
Sourcepub fn finish(&self, input: &InputState)
pub fn finish(&self, input: &InputState)
End the DOM’s build phase.
Sourcepub fn root(&self) -> WidgetId
pub fn root(&self) -> WidgetId
Gives the root widget in the DOM. This widget will always exist.
Sourcepub fn request_focus(&self, id: WidgetId)
pub fn request_focus(&self, id: WidgetId)
Request focus for the given widget id
Sourcepub fn current(&self) -> WidgetId
pub fn current(&self) -> WidgetId
If the DOM is being built, tells which widget is currently being built.
This method only gives valid results when called from inside a
Widget lifecycle method.
Sourcepub fn get_current(&self) -> Ref<'_, DomNode>
pub fn get_current(&self) -> Ref<'_, DomNode>
Returns a reference to the current DOM node. See Dom::current.
Sourcepub fn get(&self, id: WidgetId) -> Option<Ref<'_, DomNode>>
pub fn get(&self, id: WidgetId) -> Option<Ref<'_, DomNode>>
Get the node with the given widget ID.
Sourcepub fn get_mut(&self, id: WidgetId) -> Option<RefMut<'_, DomNode>>
pub fn get_mut(&self, id: WidgetId) -> Option<RefMut<'_, DomNode>>
Get a mutable reference to the node with the given widget ID.
Sourcepub fn get_global_or_init<T, F>(&self, init: F) -> T
pub fn get_global_or_init<T, F>(&self, init: F) -> T
Get a piece of DOM-global state or initialize it with the given function.
This is intended for any state that is global. It’s not a perfect fit for scoped state like themes.
Sourcepub fn do_widget<T: Widget>(&self, props: T::Props<'_>) -> Response<T::Response>
pub fn do_widget<T: Widget>(&self, props: T::Props<'_>) -> Response<T::Response>
Convenience method for calling Dom::begin_widget immediately
followed by Dom::end_widget.
Sourcepub fn begin_widget<T: Widget>(
&self,
props: T::Props<'_>,
) -> Response<T::Response>
pub fn begin_widget<T: Widget>( &self, props: T::Props<'_>, ) -> Response<T::Response>
Begin building a widget with the given type and props.
After calling this method, children can be added to this widget.
Sourcepub fn end_widget<T: Widget>(&self, id: WidgetId)
pub fn end_widget<T: Widget>(&self, id: WidgetId)
Finish building the widget with the given ID. Must be the top of the stack, with no other widgets pending.