fyne
fyne copied to clipboard
Shortcuts don't work in System Tray
Checklist
- [X] I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
- [X] This issue only relates to a single bug. I will open new issues for any other problems.
Describe the bug
Setting a shortcut to a system tray menu does not work. It does not show the text and it doesn't react to the key combinations either.
How to reproduce
- Run the code below
- Click on the System Tray Icon
- Check there are no shortcuts attached to the menu items
- Press the key combination Command+S
- Check nothing is printed in the console
- Open the window main menu
- Check the shortcuts are present
- Press the key combination Command+S
- Check
Showing...
is printed in the console
Screenshots
Example code
import (
"fmt"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("SysTray")
show := fyne.NewMenuItem("Show", func() {
fmt.Println("Showing...")
w.Show()
})
m := fyne.NewMenu("MyApp",
show)
w.SetMainMenu(fyne.NewMainMenu(m))
show.Shortcut = &desktop.CustomShortcut{Modifier: fyne.KeyModifierShortcutDefault, KeyName: "S"}
if desk, ok := a.(desktop.App); ok {
desk.SetSystemTrayMenu(m)
}
w.SetContent(widget.NewLabel("Fyne System Tray"))
w.SetCloseIntercept(func() {
w.Hide()
})
w.ShowAndRun()
}
Fyne version
2.3.5
Go compiler version
1.19.3
Operating system and version
macOS 12.3 Monterey
Additional Information
No response