Skip to main content

ContextItem

Struct ContextItem 

Source
pub struct ContextItem<Msg> { /* private fields */ }
Expand description

One row of a menu: an action, a submenu or a gap between groups.

Style keys: context-menu (bg), context-item with hover and disabled, context-item.danger, context-item-shortcut, context-item-chevron, context-item-detail.

Implementations§

Source§

impl<Msg> ContextItem<Msg>

Source

pub fn new(label: impl Into<String>, message: Msg) -> Self

An action labelled label that sends message when chosen.

Source

pub fn submenu( label: impl Into<String>, items: impl IntoIterator<Item = Self>, ) -> Self

A row that opens items beside the menu.

Source

pub fn gap() -> Self

An empty row that separates groups; menus never draw lines.

Source

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

Icon key drawn before the label.

Source

pub fn shortcut(self, label: impl Into<String>) -> Self

Faint key label kept at the right edge, e.g. "ctrl r". It only describes the key; bind the key itself in the keymap.

Source

pub fn detail(self, text: impl Into<String>) -> Self

A faint note on the right of the row, before the shortcut or the submenu arrow when there is one, e.g. why the entry cannot be used: "bsdtar needed". It is plain text in the quiet tone, drawn on disabled rows too. The menu widens to fit it, and where the menu has no room the note is cut before the label is.

Source

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

Greys the row out; it cannot be chosen or highlighted.

Source

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

Draws the row in the danger colour, for destructive actions such as delete.

Trait Implementations§

Source§

impl<Msg: Clone> Clone for ContextItem<Msg>

Source§

fn clone(&self) -> Self

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<Msg: Debug> Debug for ContextItem<Msg>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<Msg: Eq> Eq for ContextItem<Msg>

Source§

impl<Msg: PartialEq> PartialEq for ContextItem<Msg>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<Msg: PartialEq> StructuralPartialEq for ContextItem<Msg>

Auto Trait Implementations§

§

impl<Msg> Freeze for ContextItem<Msg>
where Option<Msg>: Freeze, Vec<ContextItem<Msg>>: Freeze,

§

impl<Msg> RefUnwindSafe for ContextItem<Msg>

§

impl<Msg> Send for ContextItem<Msg>
where Option<Msg>: Send, Vec<ContextItem<Msg>>: Send,

§

impl<Msg> Sync for ContextItem<Msg>
where Option<Msg>: Sync, Vec<ContextItem<Msg>>: Sync,

§

impl<Msg> Unpin for ContextItem<Msg>
where Option<Msg>: Unpin, Vec<ContextItem<Msg>>: Unpin,

§

impl<Msg> UnsafeUnpin for ContextItem<Msg>

§

impl<Msg> UnwindSafe for ContextItem<Msg>

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.