pub struct MenuButton(/* private fields */);Expand description
A button that opens a menu of actions, as the platform makes one: a
pull-down NSPopUpButton, a gtk::MenuButton, a DropDownButton, a
QQC2.Button that opens a QQC2.Menu. Each draws its own arrow. The
menu is built as a context menu is, and an item’s on_select runs when
it’s chosen. It has no click of its own: clicking opens the menu.
MenuButton::new("Add").icon(add_icon).menu((
MenuItem::new("Disc image…").on_select(add_image),
MenuItem::new("Folder…").on_select(add_folder),
MenuSeparator,
MenuItem::new("Guest tools").on_select(add_tools),
))Implementations§
Source§impl MenuButton
impl MenuButton
pub fn new(label: impl IntoValue<String>) -> MenuButton
Its menu: MenuItems, MenuSeparators and submenus (Menu).
Its menu, built by entries, and built again whenever what it reads
changes: the folders above this one, say.
MenuButton::new("Recent").menu_with(move || {
recent.get().into_iter().map(|path| MenuItem::new(path.clone()).on_select(move || open(&path))).collect::<Vec<_>>()
})Its menu, built by entries each time the platform opens it, for
a menu that depends on what’s true at that moment, as
context_menu_on_open
builds a context menu. What it reads is read then, not followed.
Sourcepub fn vector_icon(self, icon: impl IntoValue<VectorIcon>) -> MenuButton
pub fn vector_icon(self, icon: impl IntoValue<VectorIcon>) -> MenuButton
An icon before its caption, as for Button::icon.
The app’s own icon before its caption, as for
Button::vector_icon.
pub fn icon(self, name: impl IntoValue<String>) -> MenuButton
Sourcepub fn icon_only(self, only: impl IntoValue<bool>) -> MenuButton
pub fn icon_only(self, only: impl IntoValue<bool>) -> MenuButton
Shows only its icon (and the platform’s arrow). The caption stays its accessible name.
How the button is drawn: see ButtonStyle.
pub fn enabled(self, enabled: impl IntoValue<bool>) -> MenuButton
Sourcepub fn native(self, tweak: Tweak<MenuButton>) -> MenuButton
pub fn native(self, tweak: Tweak<MenuButton>) -> MenuButton
Raw platform settings, past the semantic ones: see Tweak.
Trait Implementations§
Source§impl ElementBuilder for MenuButton
impl ElementBuilder for MenuButton
fn element(&mut self) -> &mut Element
Source§fn style(self, f: impl FnOnce(&mut Style)) -> Self
fn style(self, f: impl FnOnce(&mut Style)) -> Self
Source§fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self
fn style_with(self, f: impl Fn(&mut Style) + 'static) -> Self
f re-runs whenever the
signals it reads change, and must set every field it cares about.fn width(self, value: impl IntoValue<Length>) -> Self
fn height(self, value: impl IntoValue<Length>) -> Self
fn min_width(self, value: impl IntoValue<Length>) -> Self
fn min_height(self, value: impl IntoValue<Length>) -> Self
fn max_width(self, value: impl IntoValue<Length>) -> Self
fn max_height(self, value: impl IntoValue<Length>) -> Self
fn aspect_ratio(self, value: impl IntoValue<f32>) -> Self
fn padding(self, value: impl IntoValue<Length>) -> Self
fn padding_x(self, value: impl IntoValue<Length>) -> Self
fn padding_y(self, value: impl IntoValue<Length>) -> Self
fn padding_start(self, value: impl IntoValue<Length>) -> Self
fn padding_end(self, value: impl IntoValue<Length>) -> Self
fn padding_top(self, value: impl IntoValue<Length>) -> Self
fn padding_bottom(self, value: impl IntoValue<Length>) -> Self
fn margin(self, value: impl IntoValue<Length>) -> Self
fn margin_x(self, value: impl IntoValue<Length>) -> Self
fn margin_y(self, value: impl IntoValue<Length>) -> Self
fn margin_start(self, value: impl IntoValue<Length>) -> Self
fn margin_end(self, value: impl IntoValue<Length>) -> Self
fn margin_top(self, value: impl IntoValue<Length>) -> Self
fn margin_bottom(self, value: impl IntoValue<Length>) -> Self
fn grow(self, value: impl IntoValue<f32>) -> Self
fn shrink(self, value: impl IntoValue<f32>) -> Self
fn basis(self, value: impl IntoValue<Length>) -> Self
fn align_self(self, value: impl IntoValue<Align>) -> Self
Source§fn justify_self(self, value: impl IntoValue<Align>) -> Self
fn justify_self(self, value: impl IntoValue<Align>) -> Self
Source§fn top(self, value: impl IntoValue<Length>) -> Self
fn top(self, value: impl IntoValue<Length>) -> Self
absolute()).fn bottom(self, value: impl IntoValue<Length>) -> Self
Source§fn start(self, value: impl IntoValue<Length>) -> Self
fn start(self, value: impl IntoValue<Length>) -> Self
fn end(self, value: impl IntoValue<Length>) -> Self
fn grid_column(self, value: impl IntoValue<GridPlacement>) -> Self
fn grid_row(self, value: impl IntoValue<GridPlacement>) -> Self
fn direction(self, value: impl IntoValue<TextDirection>) -> Self
display the node had.fn size( self, width: impl IntoValue<Length>, height: impl IntoValue<Length>, ) -> Self
Source§fn tooltip(self, text: impl IntoValue<String>) -> Self
fn tooltip(self, text: impl IntoValue<String>) -> Self
entries, and built again whenever what it
reads changes, as Menu::children_with builds its entries.entries each time the platform opens it,
for a menu that depends on what’s selected or under the pointer at
that moment: a table row’s menu acting on the selection. What it
reads is read then, not followed.