Skip to content

Commit

Permalink
Merge pull request #3494 from andydotxyz/fix/systraysubtap
Browse files Browse the repository at this point in the history
Listen to submenu item taps
  • Loading branch information
andydotxyz authored Dec 22, 2022
2 parents 8e4eaa2 + 6313f34 commit 175017e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions internal/driver/glfw/driver_desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,24 @@ func itemForMenuItem(i *fyne.MenuItem, parent *systray.MenuItem) *systray.MenuIt
func (d *gLDriver) refreshSystray(m *fyne.Menu) {
d.systrayMenu = m
systray.ResetMenu()
d.refreshSystrayMenu(m, nil)

systray.AddSeparator()
quit := systray.AddMenuItem("Quit", "Quit application")
go func() {
<-quit.ClickedCh
d.Quit()
}()
}

func (d *gLDriver) refreshSystrayMenu(m *fyne.Menu, parent *systray.MenuItem) {
for _, i := range m.Items {
item := itemForMenuItem(i, nil)
item := itemForMenuItem(i, parent)
if item == nil {
continue // separator
}
if i.ChildMenu != nil {
for _, c := range i.ChildMenu.Items {
itemForMenuItem(c, item)
}
continue
d.refreshSystrayMenu(i.ChildMenu, item)
}

fn := i.Action
Expand All @@ -123,13 +131,6 @@ func (d *gLDriver) refreshSystray(m *fyne.Menu) {
}
}()
}

systray.AddSeparator()
quit := systray.AddMenuItem("Quit", "Quit application")
go func() {
<-quit.ClickedCh
d.Quit()
}()
}

func (d *gLDriver) SetSystemTrayIcon(resource fyne.Resource) {
Expand Down

0 comments on commit 175017e

Please sign in to comment.