pub struct Menu { /* private fields */ }Expand description
A list of commands that pops up: open it with Ui::open_popup (a context menu) or
from a MenuBar.
The pointer highlights entries and a release on a command chooses it; a submenu opens
beside its entry when the pointer comes over it. Up and Down move the highlight, Enter or
Space chooses, Right opens a submenu and Left or Escape closes one; a key the menu does
not use goes on to what opened it (Left and Right switch a menu bar’s menus). Choosing a
command reports ActionKind::Command and closes every menu.
Implementations§
Source§impl Menu
impl Menu
Sourcepub fn new(items: impl IntoIterator<Item = MenuItem>) -> Self
pub fn new(items: impl IntoIterator<Item = MenuItem>) -> Self
A menu of items.
Sourcepub fn highlighting_first(self) -> Self
pub fn highlighting_first(self) -> Self
The menu with its first available entry highlighted, as when opened from the keyboard.
Sourcepub fn highlighted(&self) -> Option<usize>
pub fn highlighted(&self) -> Option<usize>
The entry highlighted, by index.
Trait Implementations§
Source§impl Widget for Menu
impl Widget for Menu
Source§fn accepts_focus(&self) -> bool
fn accepts_focus(&self) -> bool
A menu takes the keyboard when it opens, except a submenu opened by hovering, which takes it when the pointer comes over it (the parent keeps it meanwhile).
Source§fn measure(&mut self, cx: &mut LayoutCx<'_>, _: Constraints) -> Size
fn measure(&mut self, cx: &mut LayoutCx<'_>, _: Constraints) -> Size
constraints, for a widget without children (one
with children is sized by its style and its children). Physical pixels.Source§fn paint(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)
fn paint(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)
Source§fn event(&mut self, cx: &mut EventCx<'_>, event: &Event<'_>) -> Handled
fn event(&mut self, cx: &mut EventCx<'_>, event: &Event<'_>) -> Handled
event. An event the widget does not handle goes on to its parent.Source§fn accessibility(&self, cx: &PaintCx<'_>, node: &mut AccessNode)
fn accessibility(&self, cx: &PaintCx<'_>, node: &mut AccessNode)
node, which starts as a
Role::Group with the widget’s rectangle. Called only while
assistive technology is listening; it may allocate.