Skip to main content

Node

Struct Node 

Source
pub struct Node {
Show 17 fields pub style: Style, pub text: Option<TextContent>, pub image: Option<ImageContent>, pub tick: Option<Rgba>, pub children: Vec<Node>, pub on_tap: Option<String>, pub model: Option<String>, pub multiline: bool, pub options: Option<Vec<String>>, pub hidden: bool, pub id: Option<String>, pub label_for: Option<String>, pub focus_model: Option<String>, pub state_path: Option<Vec<usize>>, pub access: Access, pub instance: Option<String>, pub key: Option<String>,
}
Expand description

A node in the view tree: a style, optional text, children, and an optional @tap handler (raw handler source, run by the shell on tap).

Fields§

§style: Style§text: Option<TextContent>§image: Option<ImageContent>

<image src=…>.

§tick: Option<Rgba>

A checkmark stroked to fill this box, in the given colour. Drawn as a path rather than a font glyph, since ✓ is whatever the system font happens to ship, which is not a control mark.

§children: Vec<Node>§on_tap: Option<String>§model: Option<String>

r-model signal name for <input> nodes (focus target + edit binding).

§multiline: bool

type="textarea": a multi-line text input, Enter inserts a newline.

§options: Option<Vec<String>>

type="select": the bound :options, so the shell can open a dropdown.

§hidden: bool

r-show="false": laid out (space reserved) but not painted.

§id: Option<String>

id="…": a stable identifier a label’s for= can target.

§label_for: Option<String>

for="…" on a label, the id of the input it labels. Resolved at build time (the label inherits its target’s @tap), so tapping the label toggles the target the same way tapping the target would.

§focus_model: Option<String>

A label whose for= targets a text input: the target input’s r-model. The layout emits a FocusRegion here so tapping the label focuses that input (the caret lands in the input itself, matched by model).

§state_path: Option<Vec<usize>>

This node’s tree path, set only when some :hover/:active rule could match it. The layout emits a StateRegion for such nodes so the shell can tell what the pointer is over and hand the path back as interaction state. None: the common case, costs nothing.

§access: Access

What this element is, for assistive technology.

§instance: Option<String>

Which component instance this node belongs to, when it is inside one.

A component’s own state is private to the instance, so a handler written in a component has to say which instance it is running in: two <panel> elements are two separate sets of state, and the handler text is identical in both.

§key: Option<String>

r-key on an r-for row: which item this node stands for, rather than which slot it happens to occupy.

Without it a list is identified by position, so reordering the data moves every row’s identity by one and anything attached to a row (the caret, most visibly) stays behind with the slot. The runtime uses this to follow a row across a reorder. Layout itself ignores it.

Implementations§

Source§

impl Node

Source

pub fn new(style: Style) -> Self

Source

pub fn text(style: Style, text: TextContent) -> Self

Source

pub fn image(style: Style, image: ImageContent) -> Self

Source

pub fn with(self, child: Node) -> Self

Trait Implementations§

Source§

impl Clone for Node

Source§

fn clone(&self) -> Node

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnsafeUnpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.