pub struct MenuItem {
pub label: String,
pub icon: Option<String>,
pub action: MenuAction,
pub shortcut: Option<String>,
}Expand description
A menu item that can be displayed in the Scarab Dock
Menu items represent actions that users can trigger from the dock interface. They support icons, keyboard shortcuts, and hierarchical organization through submenus.
Fields§
§label: StringDisplay label for the menu item
This is the text shown to the user in the dock interface. Keep it concise and descriptive (e.g., “Run Tests”, “Open Settings”).
icon: Option<String>Optional icon or emoji for visual identification
Can be a single emoji (e.g., “🚀”, “⚙️”) or an icon identifier. Icons help users quickly identify menu items at a glance.
action: MenuActionThe action to perform when this menu item is selected
Defines what happens when the user clicks or activates this menu item.
shortcut: Option<String>Optional keyboard shortcut hint
Display-only hint showing the keyboard shortcut (e.g., “Ctrl+T”, “Alt+B”). Note: The actual shortcut handling must be implemented separately. This field is purely informational for the UI.
Implementations§
Source§impl MenuItem
impl MenuItem
Sourcepub fn new(label: impl Into<String>, action: MenuAction) -> Self
pub fn new(label: impl Into<String>, action: MenuAction) -> Self
Sourcepub fn with_shortcut(self, shortcut: impl Into<String>) -> Self
pub fn with_shortcut(self, shortcut: impl Into<String>) -> Self
Add a keyboard shortcut hint to this menu item
Note: This is display-only. The shortcut must be registered separately through the appropriate input handling mechanism.
§Arguments
shortcut- Shortcut text (e.g., “Ctrl+B”, “Alt+Shift+T”)
§Example
use scarab_plugin_api::menu::{MenuItem, MenuAction};
let item = MenuItem::new("Save", MenuAction::Command("save".to_string()))
.with_shortcut("Ctrl+S");