revery-ui / revery

:zap: Native, high-performance, cross-platform desktop apps - built with Reason!
https://www.outrunlabs.com/revery/
MIT License
8.06k stars 196 forks source link

feat(native): system menus (macOS) #976

Closed zbaylin closed 3 years ago

zbaylin commented 4 years ago

⚠️ Work in progress ⚠️

This adds a bunch of APIs to Revery.Native.Menu for controlling menus. Currently only works on macOS, but hopefully the API I made is generalize-able to Win32/Gtk!

Et7f3 commented 4 years ago

Just to have same API: for windows https://github.com/revery-ui/revery/tree/Et7f3-native-windows-menu (it lack example, popup menu, and maybe some other fixes) the reconciler is wired.

bryphe commented 4 years ago

Very exciting! Thanks for looking into this, @zbaylin . Native menus would be such a huge step forward. Between your work and @Et7f3 's exploration on Windows - seems like we could be close!

I tried to run the example and hit this error on OSX:

Moved: 559 x 389
SOURCE FILE: MenuExample.re
Switched to example: MenuExample.re
2020-08-04 10:35:03.622 Examples[87643:1169515] revery_setOnClickForMenuItem_cocoa: <NSMenuItem: 0x7f8f8ed10d70 Item #0>
2020-08-04 10:35:03.623 Examples[87643:1169515] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKeyedSubscript:]: key cannot be nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff2e5b99a9 __exceptionPreprocess + 256
    1   libobjc.A.dylib                     0x00007fff58cc1a17 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff2e5f89a4 -[CFPrefsConfigurationFileSource initWithConfigurationPropertyList:containingPreferences:] + 0
    3   CoreFoundation                      0x00007fff2e511019 -[__NSDictionaryM setObject:forKeyedSubscript:] + 921
    4   Examples                            0x000000010356eb53 revery_setOnClickForMenuItem + 83
    5   Examples                            0x0000000103149f24 camlMenuExample__fun_1710 + 68
)
libc++abi.dylib: terminating with uncaught exception of type NSException