pub struct Element {
pub kind: WidgetKind,
pub style: Style,
pub a11y: A11yProps,
pub test_id: Option<String>,
pub tab_index: Option<u32>,
/* private fields */
}Expand description
A node description: kind, style, props (static or reactive), handlers,
semantics and children. Widgets wrap an Element and add typed methods.
Fields§
§kind: WidgetKind§style: Style§a11y: A11yProps§test_id: Option<String>§tab_index: Option<u32>Implementations§
Source§impl Element
impl Element
pub fn new(kind: WidgetKind) -> Element
Sourcepub fn prop<T: Clone + 'static>(
&mut self,
value: Value<T>,
to_prop: impl Fn(T) -> Prop + 'static,
)
pub fn prop<T: Clone + 'static>( &mut self, value: Value<T>, to_prop: impl Fn(T) -> Prop + 'static, )
Sets a prop from a static or reactive value. Reactive values get an effect that updates the native widget whenever they change.
Sourcepub fn a11y_text(
&mut self,
value: Value<String>,
apply: impl Fn(&mut A11yProps, String) + 'static,
)
pub fn a11y_text( &mut self, value: Value<String>, apply: impl Fn(&mut A11yProps, String) + 'static, )
Sets a text of the node’s semantics (its label, its description) from a static or reactive value: a message follows the language.
Sourcepub fn style_prop<T: Clone + 'static>(
&mut self,
value: Value<T>,
apply: impl Fn(&mut Style, T) + 'static,
)
pub fn style_prop<T: Clone + 'static>( &mut self, value: Value<T>, apply: impl Fn(&mut Style, T) + 'static, )
Sets part of the style from a static or reactive value.
pub fn on(&mut self, handler: impl Fn(&UiEvent) + 'static)
Sourcepub fn on_key(&mut self, shortcut: Shortcut, handler: impl Fn() + 'static)
pub fn on_key(&mut self, shortcut: Shortcut, handler: impl Fn() + 'static)
Takes shortcut while the node, or a control inside it, has
keyboard focus (Prop::Keys), and runs handler when it’s pressed.
For containers, groups, lists and tables.
Sourcepub fn on_hover(&mut self, handler: impl Fn(bool) + 'static)
pub fn on_hover(&mut self, handler: impl Fn(bool) + 'static)
Reports the pointer coming over the node (Prop::Hover), and runs
handler with whether it’s over it. For containers and groups.
Sourcepub fn on_double_click(&mut self, handler: impl Fn() + 'static)
pub fn on_double_click(&mut self, handler: impl Fn() + 'static)
Reports a double click on the node (Prop::DoubleClick), and runs
handler for it. For containers and groups.
Sourcepub fn on_click(&mut self, handler: impl Fn() + 'static)
pub fn on_click(&mut self, handler: impl Fn() + 'static)
Reports a click on the node (Prop::Click), and runs handler for
it. For containers and groups.
Sourcepub fn after_build(&mut self, f: impl FnOnce(&Ui, NodeId) + 'static)
pub fn after_build(&mut self, f: impl FnOnce(&Ui, NodeId) + 'static)
Runs f right after the node is created, in the building scope.
pub fn add_children(&mut self, children: impl Children)
Trait Implementations§
Source§impl ElementBuilder for Element
impl ElementBuilder for Element
fn element(&mut self) -> &mut Element
Source§fn style(self, f: impl FnOnce(&mut Style)) -> Self
fn style(self, f: impl FnOnce(&mut Style)) -> Self
Source§fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self
fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self
f re-runs whenever the
signals it reads change, and must set every field it cares about.fn width(self, value: impl IntoValue<Length>) -> Self
fn height(self, value: impl IntoValue<Length>) -> Self
fn min_width(self, value: impl IntoValue<Length>) -> Self
fn min_height(self, value: impl IntoValue<Length>) -> Self
fn max_width(self, value: impl IntoValue<Length>) -> Self
fn max_height(self, value: impl IntoValue<Length>) -> Self
fn aspect_ratio(self, value: impl IntoValue<f32>) -> Self
fn padding(self, value: impl IntoValue<Length>) -> Self
fn padding_x(self, value: impl IntoValue<Length>) -> Self
fn padding_y(self, value: impl IntoValue<Length>) -> Self
fn padding_start(self, value: impl IntoValue<Length>) -> Self
fn padding_end(self, value: impl IntoValue<Length>) -> Self
fn padding_top(self, value: impl IntoValue<Length>) -> Self
fn padding_bottom(self, value: impl IntoValue<Length>) -> Self
fn margin(self, value: impl IntoValue<Length>) -> Self
fn margin_x(self, value: impl IntoValue<Length>) -> Self
fn margin_y(self, value: impl IntoValue<Length>) -> Self
fn margin_start(self, value: impl IntoValue<Length>) -> Self
fn margin_end(self, value: impl IntoValue<Length>) -> Self
fn margin_top(self, value: impl IntoValue<Length>) -> Self
fn margin_bottom(self, value: impl IntoValue<Length>) -> Self
fn grow(self, value: impl IntoValue<f32>) -> Self
fn shrink(self, value: impl IntoValue<f32>) -> Self
fn basis(self, value: impl IntoValue<Length>) -> Self
fn align_self(self, value: impl IntoValue<Align>) -> Self
Source§fn justify_self(self, value: impl IntoValue<Align>) -> Self
fn justify_self(self, value: impl IntoValue<Align>) -> Self
Source§fn top(self, value: impl IntoValue<Length>) -> Self
fn top(self, value: impl IntoValue<Length>) -> Self
absolute()).fn bottom(self, value: impl IntoValue<Length>) -> Self
Source§fn start(self, value: impl IntoValue<Length>) -> Self
fn start(self, value: impl IntoValue<Length>) -> Self
fn end(self, value: impl IntoValue<Length>) -> Self
fn grid_column(self, value: impl IntoValue<GridPlacement>) -> Self
fn grid_row(self, value: impl IntoValue<GridPlacement>) -> Self
fn direction(self, value: impl IntoValue<TextDirection>) -> Self
display the node had.fn size( self, width: impl IntoValue<Length>, height: impl IntoValue<Length>, ) -> Self
Source§fn tooltip(self, text: impl IntoValue<String>) -> Self
fn tooltip(self, text: impl IntoValue<String>) -> Self
entries, and built again whenever what it
reads changes, as Menu::children_with builds its entries.entries each time the platform opens it,
for a menu that depends on what’s selected or under the pointer at
that moment: a table row’s menu acting on the selection. What it
reads is read then, not followed.