This PR introduces submenu functionality for Zed's dropdown/context menus. <img width="600" height="830" alt="Screenshot 2025-12-27 at 2 03@2x" src="https://github.com/user-attachments/assets/eadfcd74-07fe-4a1f-be76-11b547c16dc8" /> ```rs .submenu("Trigger", |menu, _, _| { menu.entry("Item…", None, |_, _| {}) .entry("Item…", None, |_, _| {}) }) ``` Release Notes: - N/A --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
38 lines
1.1 KiB
Rust
38 lines
1.1 KiB
Rust
use gpui::actions;
|
|
|
|
// If the zed binary doesn't use anything in this crate, it will be optimized away
|
|
// and the actions won't initialize. So we just provide an empty initialization function
|
|
// to be called from main.
|
|
//
|
|
// These may provide relevant context:
|
|
// https://github.com/rust-lang/rust/issues/47384
|
|
// https://github.com/mmastrac/rust-ctor/issues/280
|
|
pub fn init() {}
|
|
|
|
actions!(
|
|
menu,
|
|
[
|
|
/// Cancels the current menu operation.
|
|
Cancel,
|
|
/// Confirms the selected menu item.
|
|
Confirm,
|
|
/// Performs secondary confirmation action.
|
|
SecondaryConfirm,
|
|
/// Selects the previous item in the menu.
|
|
SelectPrevious,
|
|
/// Selects the next item in the menu.
|
|
SelectNext,
|
|
/// Selects the first item in the menu.
|
|
SelectFirst,
|
|
/// Selects the last item in the menu.
|
|
SelectLast,
|
|
/// Enters a submenu (navigates to child menu).
|
|
SelectChild,
|
|
/// Exits a submenu (navigates to parent menu).
|
|
SelectParent,
|
|
/// Restarts the menu from the beginning.
|
|
Restart,
|
|
EndSlot,
|
|
]
|
|
);
|