Skip to main content

Module native_menu

Module native_menu 

Source
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 rgpui::MenuItems (see [NativeMenu::from_menu_items] / From<rgpui::Menu>).

use rgpui_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§

NativeMenu
A menu rendered by the operating system.