pub struct NativeMenu { /* private fields */ }Expand description
A menu rendered by the operating system.
Build it with the NativeMenu::menu / NativeMenu::separator builders,
then call NativeMenu::show to display it at a position.
Implementations§
Source§impl NativeMenu
impl NativeMenu
Append a clickable item that dispatches action when selected.
Append an item, controlling its disabled state.
Append an item, controlling its checked state (a check mark is shown).
Append an item showing icon next to its label.
Native platform menus load absolute paths ([Path::is_absolute]) from the filesystem,
and every other path through the application gpui::AssetSource.
crate::IconName resolves as an asset and works across all backends.
- macOS: loaded into an
NSImageas a template image, so it tints with the item text and assigned to the item ([NSMenuItem::image]). - Windows: loaded into an
HBITMAPand set as the item’s content bitmap (MENUITEMINFOW::hbmpItem), shown beside the label. SVG files are rasterized, withresvg; other formats (PNG, JPEG, BMP, …) are decoded by GDI+. Other platforms (fallback): rendered as the menu item’scrate::Icon.
Note: this is the menu item’s content icon, not its state/check-mark indicator.
Append an item showing icon next to its label, controlling its disabled state.
Same icon behavior as Self::menu_with_icon. Use this when an item
carries an icon but should be greyed out.
Add Menu Item with Icon and disabled state.
Alias for Self::menu_with_icon_disabled, matching crate::menu::PopupMenu.
Append a submenu built from another NativeMenu.
Sourcepub fn show(self, position: Point<Pixels>, window: &mut Window, cx: &mut App)
pub fn show(self, position: Point<Pixels>, window: &mut Window, cx: &mut App)
Pop up the menu at position (window coordinates, in logical pixels).
The menu is shown without blocking the caller: the OS tracking loop runs
off GPUI’s call stack, so GPUI is not borrowed while it is open. When an
item is selected, its action is dispatched via Window::dispatch_action.
Trait Implementations§
Source§impl Default for NativeMenu
impl Default for NativeMenu
Source§fn default() -> NativeMenu
fn default() -> NativeMenu
Source§impl From<Menu> for NativeMenu
Reuse an existing GPUI menu definition as a native menu.
impl From<Menu> for NativeMenu
Reuse an existing GPUI menu definition as a native menu.
Actions, separators, submenus, checked, and disabled are mapped over;
system menus (e.g. macOS Services) have no native popup equivalent and are
skipped.
Auto Trait Implementations§
impl !RefUnwindSafe for NativeMenu
impl !Send for NativeMenu
impl !Sync for NativeMenu
impl !UnwindSafe for NativeMenu
impl Freeze for NativeMenu
impl Unpin for NativeMenu
impl UnsafeUnpin for NativeMenu
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().