-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat: add a default menu for tauri apps #2398
Comments
I just talked with @lemarier a couple hours ago about this and I took some inspiration from electron. Here is proposed changes which is breaking so @lucasfernog input here is vital. Changes needed in tao:
Changes in tauri:
Example: tauri::Builder::default()
.setup(|app|{
// get default menu or current one
let app_menu = app.get_app_menu();
// extend the menu
app_menu.add_submenu("MyMenu");
// set the updated app menu, or pass None to remove it
app.set_app_menu(Some(app_menu));
})
.on_page_load(|win, _|{
// get default menu or current one that is attached to the window, only linux and windows
let menu = win.get_menu();
// extend the menu
menu.add_submenu("MyMenu");
// set the updated menu, or pass None to remove it, only for linux and windows
win.set_menu(Some(menu));
})
.run(tauri.generate_context!())
.expect("Error while running tauri application") |
Sounds like a great way to go about it :D |
I like this way @amrbashir. Thank you @probablykasper for raising this issue. I've been studying and using Tauri for the last week and this is a particular issue that is boring and that can become unaware for Windows and Linux Developers. I was surprised why I could quit my app using a Command + Q, or select all the text Command + A. Would be really useful to have this ready for Mac users, or at least a ready documentation for unexperienced people in Tauri like me 😄 ❤️ |
The more I'm thinking about it, the more I think it should go directly in If the user does not define a menu, we build the default menu. Maybe we could also add a I think we shouldn't overengineering here and if the user wants a custom menu he should create it from scratch. Allowing default menu extensions could bring a lot of weird bugs. We already expose all the native elements so it's a big plus. The default menu should be the one suggested y the Apple developer guidelines. What you think @amrbashir |
Tbh, I think Tao and Wry are low-level libraries and we shouldn't provide any default menus there as users of these libraries expect to be in full control so it makes sense to let them worry about menus.
I don't think that allowing menu extensions can bring bugs since we only need to allow adding new sub menus, it is just basic extension, if users want to delete menus or modify it then they should create their own menu from scratch.
default or non-default menu should be disabled through
I don't have an opinion about this, as long as the default menu is sensible across all platforms. |
I don't think the changes needed in Tao are considered over engineering since they are minimal changes and tbh are necessary.
|
@amrbashir I think it probably should be in tao. It's better to accidentally have a menu than to accidentally not have one |
As I said earlier, Tao/Wry users expected it to be bare-bones minimal, and they expect to build their app from ground up so I think Tao/Wry should only provide the means for them and not ship predefined designs for them but don't worry Tauri should and probably will ship a default menu for Tauri users as Tauri is considered more of a high-level tool than Tao/Wry. |
@lemarier suggested that if a user wants a custom menu, they should create it from scratch. After implementing submenu defaults in my template, I have to say it's extremely nice to have: Saves a nice 40 LOC and makes it all easier to manage, especially when it comes to cross-platform differences. |
Just wanted to add in my two cents that I think this would be a very nice default to add in. A lot of functionality you expect out of the box (like command-Q, copy, paste, cut, etc.) exist in every single macOS application. Would really help new developers (like myself) to get started prototyping with a lower barrier to entry in Tauri. |
Since default menu with basic copy/paste/undo/redo functionality is not presented in Tao and Tauri yet, maybe we should add it to the docs? |
Description --- - Adds Copy, Cut, Paste, SelectAll, Undo, Redo and Quit to menu items - Command + ? keys are now working on Mac - Upgraded Tauri lib to 1.0.0.rc.2 Motivation and Context --- These are basic and expected features for desktop apps. Not able to set the mac default menu title, seems that is not currently possible (Ref tauri-apps/tauri#2398) How Has This Been Tested? --- Manually
This would be trivial to PR, since the issue itself provides almost all of the code necessary. I am willing to PR support for this (including docs), if it was to be merged? |
What would it take to start adding in a default menu building in tauri/tao now (even if we don't enable it for new projects by default)? I'm thinking along the lines of how SvelteKit does a new project: you choose a skeleton project or a more feature-packed project. If in create-tauri-app we mimic this and then just add the default menu if a feature-packed option is chosen, then we give that flexibility to the user during init. By building out a sort of option like this in create-tauri-app, would could also demo some of the APIs (thinking to have a simple rust function that returns a string and then have the frontend show that in a dialog) to give the user a concrete place to jump off from. |
A default menu should be included directly in |
Nice improvement! |
Wonderful addition and it seems this has been closed and (apparently) merged if I follow all the links but how do you actually use it? Is it merged but not yet released? What version of the common |
|
On macOS, it's pretty much standard for every app to have a menu. Not having one looks very unusual, and basic shortcuts like copy/paste don't work (#2397). This could result in future issues being created, and unexpected surprises for people who develop on Windows/Linux.
To prevent that, I think it would make sense to have a default macOS menu.
Suggestion for what the default menu should be, and API for it:
The text was updated successfully, but these errors were encountered: