AlexTorresDev / custom-electron-titlebar

Custom electon title bar inpire on VS Code title bar
MIT License
870 stars 149 forks source link

Not sure how to add menu items #239

Closed Christilut closed 1 year ago

Christilut commented 1 year ago

I've been using version 3 for quite a while and very happy with it, but I had to upgrade because of Electron.

I can't figure out how to add menu items. I used to do titlebar.updateMenu(...) and new Titlebar({ menu: ... }) but the former doesn't exist anymore (I think) and the latter is deprecated according to the wiki (and doesn't seem to exist at all in v4.2.7). The wiki refers to using "setupTitlebar" but I can't find any reference to that function in the wiki. Typings suggest it doesn't have arguments at all.

Looked through all the wiki but I have no idea how to add menu items. What am I missing?

This page is empty, maybe that's it? https://github.com/AlexTorresDev/custom-electron-titlebar/wiki/Titlebar-Methods

Christilut commented 1 year ago

Okay turns out if you pass an invalid path to the icon parameter, the whole menu doesn't work.

If anyone else reads this: As for adding menu items, see Electron manual and use const menu = Menu.buildFromTemplate(template) and Menu.setApplicationMenu(menu) before running attachTitlebarToWindow(mainWindow)