Menus - lmparppei/BeatPlugins GitHub Wiki
You can add a menu to the top macOS menu bar for resident (running in background) plugins. The menu can't be removed until the plugin stops running, so avoid calling Beat.menu()
multiple times.
Create menu items
let item = Beat.menuItem(title, [shortcuts], callback)
shortcuts
is an array of strings. Allowed items are any alphanumeric characters and modifiers: alt
, cmd
, shift
, ctrl
.
item.on
– sets the status of the menu, whentrue
, a checkmark is displayed
let item = Beat.menuItem("Hello World", ["alt", "cmd", "x"], () => {
Beat.log("Hello world")
})
Create a menu
let menu = Beat.menu(title, [children])
Whenever a menu is crated, it's automatically added to the top menu bar. children
is an array of menu items.
menu.addItem(menuItem)
– adds a menu itemmenu.removeItem(menuItem)
– removes a menu item
Example
let items = [
Beat.menuItem("First item", ["cmd", "alt", "1"], () => { Beat.log("Hello world 1!"); }),
Beat.separatorMenuItem(),
Beat.menuItem("Second item", ["cmd", "alt", "2"], () => { Beat.log("Hello world 2!"); })
]
let menu = Beat.menu("Plugin menu", items)