pub trait Selectable: Sized {
// Required methods
fn selected(self, selected: bool) -> Self;
fn is_selected(&self) -> bool;
// Provided methods
fn secondary_selected(self, _: bool) -> Self { ... }
fn open(self, open: bool) -> Self { ... }
fn is_open(&self) -> bool { ... }
}Expand description
An element or component that exposes controlled selected state.
selected is the application’s own meaning of selection: the current
view, the active item, the chosen option. open is a separate state a
popover, menu or dropdown puts on its trigger for as long as it is open.
The two coincide on a plain button, which paints both the same way, so
open falls back to selected by default and a trigger that only
implements selected keeps working unchanged. A trigger whose selection
means something else, such as a sidebar row that is selected when it is
the current view, overrides open and is_open to keep the two apart.
Required Methods§
Provided Methods§
fn secondary_selected(self, _: bool) -> Self
Sourcefn open(self, open: bool) -> Self
fn open(self, open: bool) -> Self
Sets the open state a popover, menu or dropdown holds on its trigger while it is open.
Defaults to selected, so a trigger only overrides this when its
selected state means something other than “my popup is open”.
Sourcefn is_open(&self) -> bool
fn is_open(&self) -> bool
Whether the trigger is currently marked open.
Defaults to is_selected, matching the default of Self::open.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".