-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Menu shortcuts should be disabled while a dialog is open #5235
Comments
For reference our related discussion on Discord |
I've just realised there is some challenge here because modality means different things on different platforms. For example on macOS the menus remain visible and usable when a dialog is up iirc. |
Do you mean with Fyne apps specifically or apps in general on macOS? No, on Gnome the menus are greyed out and inactive while a modal dialog is open. That is how Fyne apps work currently (tested with the Fyne demo app) and native apps too (tested with Libre Office Calc). Same on Windows btw (tested with a one of my Fyne apps). |
I was meaning apps in general. Perhaps the original issue was missing some info about OS, because I'm a little confused now - if the menu items are being disabled as you expect then what is it that isn't right? |
What isn't right is that the menu shortcuts still work despite the menu being greyed out. This creates problems: For example if you have a menu shortcut that opens a modal dialog, this allows you to re-open the same modal multiple times, which are then shown on top of each other. And the user needs to close the same dialog multiple times to get back to the app. Here is how this looks to the user:
Screencast.from.19.01.2025.17.35.21.webmHere is the code that produces above behavior: package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Fyne Playground")
mi := fyne.NewMenuItem("About...", func() {
d := dialog.NewInformation("About", "A modal dialog", w)
d.Show()
})
mi.Shortcut = &desktop.CustomShortcut{KeyName: fyne.KeyA, Modifier: fyne.KeyModifierAlt}
w.Canvas().AddShortcut(mi.Shortcut, func(shortcut fyne.Shortcut) {
mi.Action()
})
menu := fyne.NewMainMenu(fyne.NewMenu("File", mi))
w.SetMainMenu(menu)
w.SetContent(container.NewCenter(widget.NewLabel("Welcome")))
w.Resize(fyne.NewSize(600, 300))
w.ShowAndRun()
} |
Ah right, so not when there are global menus. I was asking about when they are outside of the window in apps that are not Fyne - sorry for the confusion. On macOS it applies to all apps (because we use the global menu) whereas Linux Global is not something we support so there is a grey area there for sure. |
In my testing the apps on macOS do not universally get disabled but it seems that the app decides which menu items to disable when a modal dialog is up... |
Checklist
Is your feature request related to a problem?
In a desktop app with a menu the menu shortcuts are still active while a dialog is open. This can be a problem, because if there are shortcut that opens a dialog (e.g. a settings dialog), this allows the user to open multiple instances of the same dialog, one on top of each other. It may also be weird for users to be able to open menu items through shortcuts while a supposedly modal dialog is open. In general this behavior breaks the expectation of modality for dialogs in desktop apps.
Is it possible to construct a solution with the existing API?
As a workaround one could manually remove all menu shortcuts before a dialog is open and re-add them again when it is closed. This would have to be done for each and every dialog in the app and would result in a lot of additional boilerplate code.
Describe the solution you'd like to see.
Menu shortcuts should be automatically disabled when a dialog opens and re-enabled when it is closed. Any other shortcuts should not be affected.
The text was updated successfully, but these errors were encountered: