[−][src]Struct druid::MenuDesc
A platform-agnostic description of an application, window, or context menu.
Implementations
impl<T: Data> MenuDesc<T>
[src]
pub fn empty() -> Self
[src]
Create a new, empty menu.
pub fn new(title: LocalizedString<T>) -> Self
[src]
Create a new menu with the given title.
pub fn platform_default() -> Option<MenuDesc<T>>
[src]
If this platform always expects windows to have a menu by default,
returns a menu. Otherwise returns None
.
pub fn append_iter<I: Iterator<Item = MenuItem<T>>>(
self,
f: impl FnOnce() -> I
) -> Self
[src]
self,
f: impl FnOnce() -> I
) -> Self
Given a function that produces an iterator, appends that iterator's items to this menu.
Examples
use druid::{Command, LocalizedString, MenuDesc, MenuItem, Selector}; let num_items: usize = 4; const MENU_COUNT_ACTION: Selector<usize> = Selector::new("menu-count-action"); let my_menu: MenuDesc<u32> = MenuDesc::empty() .append_iter(|| (0..num_items).map(|i| { MenuItem::new( LocalizedString::new("hello-counter").with_arg("count", move |_, _| i.into()), Command::new(MENU_COUNT_ACTION, i), ) }) ); assert_eq!(my_menu.len(), 4);
pub fn append(self, item: impl Into<MenuEntry<T>>) -> Self
[src]
Append an item to this menu.
pub fn append_if(
self,
item: impl Into<MenuEntry<T>>,
p: impl FnMut() -> bool
) -> Self
[src]
self,
item: impl Into<MenuEntry<T>>,
p: impl FnMut() -> bool
) -> Self
Append an item to this menu if the predicate is matched.
pub fn append_separator(self) -> Self
[src]
Append a separator.
pub fn len(&self) -> usize
[src]
The number of items in the menu.
pub fn is_empty(&self) -> bool
[src]
Returns true
if the menu contains no items.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for MenuDesc<T>
impl<T> !Send for MenuDesc<T>
impl<T> !Sync for MenuDesc<T>
impl<T> Unpin for MenuDesc<T>
impl<T> !UnwindSafe for MenuDesc<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RoundFrom<T> for T
fn round_from(x: T) -> T
impl<T, U> RoundInto<U> for T where
U: RoundFrom<T>,
U: RoundFrom<T>,
fn round_into(self) -> U
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,