Skip to content

[Feature Request]: Support macOS palette menus #42960

@slice

Description

@slice

Preflight Checklist

Problem Description

I can't seem to create palette menus with Electron, which were made public API in macOS Sonoma (14). They are described here:

These allow for creating menus such as this one, from Messages:

From what I can see, Electron doesn't expose a way to create this kind of menu. You need to be able to specify the NSMenu's presentationStyle. You can seemingly embed a palette menu (NSMenu with a presentationStyle of .palette) within a larger menu by creating an NSMenuItem and setting its submenu to the palette menu.

Proposed Solution

I would like some way to create palette menus while also being able to populate the palette with images (NativeImages?) from JavaScript. This sounds a bit tricky, so I can take the time to design an API surface if wanted. However, I assume that the maintainers would do a better job than me.

My current use case doesn't involve maintaining a selection state for the items in the palette via selectionMode. In other words, I'd like to be able to use palette menus just so that I can present menu items arranged horizontally, with only images to represent the item - just like the menu in Messages. However, support for this may or may not be desired if this feature is to be added to Electron.

Alternatives Considered

You can use MenuItems with icons, but it doesn't provide the same look and feel of a palette menu. There doesn't seem to be any other way to achieve this without dropping down to the renderer and reimplementing menus there.

Additional Information

With the release of macOS Sonoma, menus (in general, across the system) were reimplemented in Cocoa and that new implementation is used within applications according to some runtime heuristics involving link checks.

A default controlling this is NSMenuEnableCarbonCompatibilityMode. The details around this are important because AIUI, Carbon menus involved a modal event-tracking loop that would run for the duration of the menu being on-screen. This would block the main AppKit thread. I believe that Cocoa menus don't use this and the main AppKit thread is able to run unencumbered with Cocoa menus visible. This is just a guess, though.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions