-
-
Notifications
You must be signed in to change notification settings - Fork 974
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
add default menu bar in dioxus-desktop to resolve #1691 #1696
Conversation
fixup naming and expose disable_default_menu_bar with builder function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one small question about a function name, but overall looks great! This will help make desktop apps work more like I would expect out of box. (I also really appreciate the detailed PR description 🙂)
Agreed, looks great, definitely something we want to support. It might be worth to make the function that builds the menubar public and then change the naming scheme to what @ealmloff mentioned. Other than that, LGTM! |
Do we want this to be the default behavior on all platforms or only on Mac? I haven't been targeting Windows or Linux recently but if I remember correctly they weren't impacted by the keybindings issue |
Actually, I don't think it is an issue on Linux or Windows, though I haven't been able to test it either. Otherwise, I do think it won't be bad to have those very basic menus included on these platforms too. It is more consistent that way, otherwise one might wonder where the menus went when cross-compiling or similar.
So you basically want to expose the standard menu bar that was built so that one could adjust it further instead of having to re-create a new Menubar when intending to customize the existing one? I think that would be nice, but I am not too sure where to put it. I thought about exposing it and accepting a MenuBar instead of a bool, but MenuBar does not implement copy / clone. Also, I think no one would expect it to be found in webview.rs when using it from the outside. If you have an idea on that I would be really happy about adjusting it, otherwise I'd suggest keeping it the way it is with the incoming naming changes and opening an issue about exposing it where we can discuss this further. |
…explanatory" This reverts commit adfbb6c.
…xplanatory Note: This is the actual correct commit. The previous one contained files touched by cargo fmt which are unrelated. Sorry for that.
@ealmloff I think this should be ready to be merged now, please check my commit history though since I had a huge fuckup in there where I committed 90 files on accident which were touched by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
It might be better to wait to merge this until the last 0.4 version goes out. If you already have the system menu added manually, it wouldn't be great to add a second menu even if the API isn't technically breaking |
Feature: add default menu bar to dioxus-desktop
It looks like this on macOS (please ignore firefox underneath it):
![image](https://private-user-images.githubusercontent.com/26353707/288544689-6a9b51b2-5ce8-44af-bf18-c97e0a36334d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxMjcxMDMsIm5iZiI6MTczOTEyNjgwMywicGF0aCI6Ii8yNjM1MzcwNy8yODg1NDQ2ODktNmE5YjUxYjItNWNlOC00NGFmLWJmMTgtYzk3ZTBhMzYzMzRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDE4NDY0M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVkYzUyYmM2YTkzNjMxOGNmMzU1N2VhYWMzZTE2YmQwZTkwNjgzMWNmODNhZWE5YmU4ZGYwOThjMDIxMGI4YjImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.yZ0BKSGS-RjfQKYFGa8AWRjbwGH_YQN1M0meqFtPYlQ)
This also resolves #1691 since, as mentioned there, macOS requires menu bar items with keybindings assigned to them to enable system default text editing and window shortcut behaviors.
Solution
The feature was implemented by adding a function
fn create_default_menu_bar() -> MenuBar
in webview.rs which constructs a platform specific menu bar that may be passed intowindow_builder
ifdisable_default_menu_bar
isfalse
which is defined in config.rs to enable the option to opt out of having a menu bar at all.diasable_default_menu_bar
isfalse
by default, and therefore thewindow_builder
will use the default menu bar if the user does not opt out, as implemented in webview.I think this should be exactly what @ealmloff described in his comment.
clippy
and all tests includingplaywright
passed onmaster
.Note: due to
tao
not supporting a lot of native menu bar items on Linux, there is no edit menu on Linux yet.Example usage
Cargo.toml
:main.rs
: