fyne icon indicating copy to clipboard operation
fyne copied to clipboard

Shortcuts don't work in System Tray

Open sk- opened this issue 1 year ago • 4 comments

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

  1. Run the code below
  2. Click on the System Tray Icon
  3. Check there are no shortcuts attached to the menu items
  4. Press the key combination Command+S
  5. Check nothing is printed in the console
  6. Open the window main menu
  7. Check the shortcuts are present
  8. Press the key combination Command+S
  9. Check Showing... is printed in the console

Screenshots

Screen Shot 2023-06-24 at 10 11 43 Screen Shot 2023-06-24 at 10 13 49

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

sk- avatar Jun 24 '23 14:06 sk-