pub trait HasFocus {
// Required methods
fn focus(&self) -> FocusFlag;
fn area(&self) -> Rect;
// Provided methods
fn build(&self, builder: &mut FocusBuilder) { ... }
fn area_z(&self) -> u16 { ... }
fn navigable(&self) -> Navigation { ... }
fn is_focused(&self) -> bool { ... }
fn lost_focus(&self) -> bool { ... }
fn gained_focus(&self) -> bool { ... }
}Expand description
Trait for a widget that has a focus flag.
When used for a widget implement
- focus()
- area() and optionally
- area_z() and navigable()
When used for a container widget implement
- build()
ⓘ
fn build(&self, builder: &mut FocusBuilder) {
let tag = builder.start(self);
builder.widget(&self.component_a);
builder.widget(&self.component_b);
builder.end(tag);
}Creates a container with an identity.
Or just
ⓘ
fn build(&self, builder: &mut FocusBuilder) {
builder.widget(&self.component_a);
builder.widget(&self.component_b);
}for an anonymous container.
focus(), area() and area_z() are only used for the first case. navigable() is ignored for containers, leave it at the default.
Required Methods§
Provided Methods§
Sourcefn build(&self, builder: &mut FocusBuilder)
fn build(&self, builder: &mut FocusBuilder)
Build the focus-structure for the container.
Sourcefn area_z(&self) -> u16
fn area_z(&self) -> u16
Z value for the area.
When testing for mouse interactions the z-value is taken into consideration too.
Declares how the widget interacts with focus.
Default is Navigation::Regular.
Sourcefn is_focused(&self) -> bool
fn is_focused(&self) -> bool
Focused?
Sourcefn lost_focus(&self) -> bool
fn lost_focus(&self) -> bool
Just lost focus.
Sourcefn gained_focus(&self) -> bool
fn gained_focus(&self) -> bool
Just gained focus.