-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: rewrite #18
Conversation
As requested here some niceties of jsMenus and other wishlist items. Note I haven't really looked at Muda or Wry's menu-creating API - currently DomTerm can use the Electron or Qt menus or jsMenus.
|
I maybe able to do that but I won't include it in this PR
Not sure if I understand this correctly, do you want to display a native menubar when the native titlebar is hiddden?
This PR implements all necessary menu modification APIs,
This is out of Tao/Wry/Muda scope, but it is possible that Tauri will provide a JS api for it in the future.
This is not possible unfortunately, as these are native menus and rendering is done by the OS. |
"Not sure if I understand this correctly, do you want to display a native menubar when the native titlebar is hiddden?" I'd like the ability to embed the menubar into a custom titlebar, as shown below. When space is tight (or depending on user/application preference) the menubar may be replaced by a hamburger menu. |
I don't think that is possible, because the custom titlebar would be in the webview while the menu is in the native window. For this situation you will have to fallback to a menu implementation in HTML/JS, similar to how VSCode has a native menu when using native title bar and a custom HTML/JS menu when using custom title bar. |
"This is not possible unfortunately, as these are native menus and rendering is done by the OS." I understand - though it is tempting to stick to jsMenus as opposed to native menus. For the record, I see these as the advantages of native menus:
|
Js menus are definitely great and they are way more flexible than native ones but each has their tradeoffs that's why I think a combination of both is good. |
"I don't think that is possible, because the custom titlebar would be in the webview while the menu is in the native window." The custom titlebar could have a transparent notch allowing the native menubar to be visible. Or (at some point in the future) use something like the new experimental Windows Controls Overlay API. "For this situation you will have to fallback to a menu implementation in HTML/JS, similar to how VSCode has a native menu when using native title bar and a custom HTML/JS menu when using custom title bar." Yes, that is more or less what I do. There is also a hybrid option: custom buttons for the menubar itself, but when you click on one you get a native popup menu. |
With a notch in the custom titlebar or with Also note that the However the
Yeah that is a viable option also. |
"you still need to a way pass the click to the window rather than the webview" That is why I fiddle with z-order when a menu (using jsMenus) is shown. Specifically, the "master" webview is brought to the front so it can get mouse and keyboard events. |
this workaround won't work with native menus on Windows at least, that's why I think a custom titlebar should be paired with a custom HTML/JS menu. |
I agree for Windows or Linux. On macOS I think it makes sense to use the system menubar even if using a custom titlebar - and in tha case we don't have to worry about embedding the menubar into the titlebar One advantage of an API like Electron's |
Sounds reasonable, and I already implemented template support using |
* partial macOS implementation * fix context menu examples * add accelerator support for macOS * strip ampersands from titles on macOS * add CMD_OR_CTRL shorthand for modifiers * implement actions for predefined menu items on macos * fix examples * more predefined items * implement insert for macos * refactor macOS implementation * menu state getters and setters on macOS * implement remove for macOS * code tweaks * add show_context_menu_for_nsview for Submenu on macOS * docs improvements * allow adding item to the same menu multiple times on macOS * implement `items` for macOS * strip only single ampersands from menu titles * add support for menu item actions on macOS * add app name to macOS About, Hide, Quit menu items * add methods to set app window and help menus on macOS * fix clickable submenu titles on macOS * refactor submenu for safe reuse on macOS * fmt & clippy * few cleanups * fix docs * clippy * fix docs * cleanup examples * fix tests
This rewrite main goal is to allow modifying the predefined (native) menu items and allow creating the menu item separately from a menu.
show_context_menu_for_ns_view
should take anx
andy
.