cosmic::widget::segmented_button

Type Alias SingleSelectEntityMut

source
pub type SingleSelectEntityMut<'a> = EntityMut<'a, SingleSelect>;
Expand description

Single-select variant of an EntityMut.

Aliased Type§

struct SingleSelectEntityMut<'a> { /* private fields */ }

Implementations

source§

impl<'a, SelectionMode: Default> EntityMut<'a, SelectionMode>
where Model<SelectionMode>: Selectable,

source

pub fn activate(self) -> Self

Activates the newly-inserted item.

model.insert().text("Item A").activate();
source

pub fn secondary<Data>( self, map: &mut SecondaryMap<Entity, Data>, data: Data, ) -> Self

Associates extra data with an external secondary map.

The secondary map internally uses a Vec, so should only be used for data that is commonly associated.

let mut secondary_data = segmented_button::SecondaryMap::default();
model.insert().text("Item A").secondary(&mut secondary_data, String::new("custom data"));
source

pub fn secondary_sparse<Data>( self, map: &mut SparseSecondaryMap<Entity, Data>, data: Data, ) -> Self

Associates extra data with an external sparse secondary map.

Sparse maps internally use a HashMap, for data that is sparsely associated.

let mut secondary_data = segmented_button::SparseSecondaryMap::default();
model.insert().text("Item A").secondary(&mut secondary_data, String::new("custom data"));
source

pub fn closable(self) -> Self

Shows a close button for this item.

source

pub fn data<Data: 'static>(self, data: Data) -> Self

Associates data with the item.

There may only be one data component per Rust type.

model.insert().text("Item A").data(String::from("custom string"));
source

pub fn divider_above(self, divider_above: bool) -> Self

source

pub fn icon(self, icon: impl Into<Icon>) -> Self

Define an icon for the item.

model.insert().text("Item A").icon(IconSource::from("icon-a"));
source

pub fn id(self) -> Entity

Returns the ID of the item that was inserted.

let id = model.insert("Item A").id();
source

pub fn indent(self, indent: u16) -> Self

source

pub fn position(self, position: u16) -> Self

Define the position of the item.

source

pub fn position_swap(self, other: Entity) -> Self

Swap the position with another item in the model.

source

pub fn text(self, text: impl Into<Cow<'static, str>>) -> Self

Defines the text for the item.

source

pub fn with_id(self, func: impl FnOnce(Entity)) -> Self

Calls a function with the ID without consuming the wrapper.