Nnextop / app

useMenu

Set the native application menu. State-hook style ([menu, setMenu]).

const [menu, setMenu] = useMenu()
  • menu: NextopAppMenuItem[] — current menu template.
  • setMenu: (next: NextopAppMenuItem[] | (prev => NextopAppMenuItem[])) => void — set/update it.
type NextopAppMenuItem = {
label?: string
type?: 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'
click?: () => void
role?: 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'pasteandmatchstyle' | 'selectall'
| 'delete' | 'minimize' | 'close' | 'quit' | 'reload' | 'forcereload' | 'toggledevtools'
| 'resetzoom' | 'zoomin' | 'zoomout' | 'togglefullscreen' | 'window' | 'help' | 'about'
| 'services' | 'hide' | 'hideothers' | 'unhide' | 'showhelp' | 'front'
accelerator?: string
submenu?: NextopAppMenuItem[]
enabled?: boolean
visible?: boolean
checked?: boolean
id?: string
toolTip?: string
registerAccelerator?: boolean
sublabel?: string
icon?: string
}
import { useMenu } from 'nextop-app'
const [, setMenu] = useMenu()
setMenu([
{
label: 'File',
submenu: [
{ label: 'New', accelerator: 'CmdOrCtrl+N', click: () => {} },
{ type: 'separator' },
{ role: 'quit' },
],
},
])