Expand description
A menu rendered natively by the operating system.
Unlike crate::menu::PopupMenu, which is drawn by GPUI and therefore
clipped to the window bounds, NativeMenu is rendered by the OS. It can
extend beyond the window โ useful for small windows where a GPUI-drawn popup
menu would otherwise be cut off.
Items carry a GPUI Action, dispatched via Window::dispatch_action
when selected โ the same mechanism the application menu bar and key bindings
use. A NativeMenu can therefore be built directly from GPUI
gpui::MenuItems (see [NativeMenu::from_menu_items] /
From<gpui::Menu>).
โ
use gpui_kit::component::native_menu::NativeMenu;
NativeMenu::new()
.menu("Copy", Box::new(Copy))
.menu("Paste", Box::new(Paste))
.separator()
.menu("Delete", Box::new(Delete))
.show(position, window, cx);Structsยง
- Native
Menu - A menu rendered by the operating system.