crossbind
GitHub
← All extensions

menu

The app's menus and context menus, the tray icon and system notifications.

Package @crossbind/extension-menunpm ↗Source ↗

An app has it by having @crossbind/core-app-host, which lists it as a dependency: there is nothing to install or list.

Use

JavaScript
import { events, menu, notification, tray } from 'crossbind/app';
 
events.on('menu', ({ id }) => run(id));
await menu.set([{ label: 'File', items: [{ label: 'Export', id: 'export', accelerator: 'CmdOrCtrl+E' }] }]);
await tray.set({ tooltip: 'My app', menu: [{ label: 'Show', id: 'show' }] });
await notification.show({ title: 'Export done', body: 'report.csv is saved.' });

A click of an item with an id is the event menu; menu.popup opens a context menu at the page's point.

Platforms

macOS, Linux and Windows; menu.setDock is macOS's alone. On a phone each call rejects. A Linux tray and its notifications go over D-Bus, and a Windows notification shows as a balloon of the tray's icon.

Replace or leave out

It holds the roles menu, notification and tray. An extension that gives replaces: 'menu' takes that role alone, and this one goes on with the rest; app: { without: ['menu'] } in crossbind.config.js leaves it out. The guide shows how, and extensions.md what a replacement answers.

app.md has the menus' items, and Tray and notifications the rest.

Type to search every guide page and section.
↑↓ navigate↵ openesc close