Skip to content

Support custom menu bar items #1

Description

@proggeramlug

Feature Request

Perry currently doesn't support adding custom menu bar items to the macOS app menu bar. Apps built with Perry get the default menu bar but have no way to add custom menus or menu items.

Use Case

When building a macOS app (e.g., a JSON viewer), it's common to expose actions like "Open File", "Paste from Clipboard", "Find", "Expand All", etc. through the menu bar. Currently the only way to trigger actions is via addKeyboardShortcut(), but there's no corresponding menu bar UI for discoverability.

Proposed API

Something like:

import { menuBarAddMenu, menuBarAddItem } from "perry/ui"

// Create a top-level menu
const fileMenu = menuBarAddMenu("File")
menuBarAddItem(fileMenu, "Open...", "o", 1, () => { openFile() })
menuBarAddItem(fileMenu, "Paste JSON", "v", 1, () => { pasteJson() })

const viewMenu = menuBarAddMenu("View")
menuBarAddItem(viewMenu, "Expand All", "1", 1, () => { expandAll() })
menuBarAddItem(viewMenu, "Collapse All", "2", 1, () => { collapseAll() })

This would allow Perry apps to have proper macOS menu bars with keyboard shortcut indicators, matching native app conventions.

Current Workaround

Using addKeyboardShortcut() for all actions and displaying keyboard hints in the app's UI (e.g., an about screen listing shortcuts). This works but isn't discoverable through the standard macOS menu bar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions