[v3 mac] Fix right click. Slight refactor.

This commit is contained in:
Lea Anthony
2023-07-10 20:44:30 +10:00
parent 7f0479d8b4
commit e7e5597c95
2 changed files with 16 additions and 9 deletions
-2
View File
@@ -68,11 +68,9 @@ func main() {
})
systemTray.SetMenu(myMenu)
systemTray.AttachWindow(window).WindowOffset(5)
err := app.Run()
if err != nil {
log.Fatal(err)
}
+16 -7
View File
@@ -33,7 +33,7 @@ type button int
const (
leftButtonDown button = 1
rightButtonDown button = 2
rightButtonDown button = 3
)
// system tray map
@@ -197,19 +197,28 @@ func (s *macosSystemTray) processClick(b button) {
s.parent.clickHandler()
return
}
if s.parent.attachedWindow.Window != nil {
s.parent.defaultClickHandler()
return
}
if s.menu != nil {
C.showMenu(s.nsStatusItem, s.nsMenu)
}
case rightButtonDown:
// Check if we have a callback
if s.parent.rightClickHandler != nil {
s.parent.rightClickHandler()
return
}
}
// Open the default menu if we have one
if s.menu != nil {
if s.menu != nil {
if s.parent.attachedWindow.Window != nil {
s.parent.attachedWindow.Window.Hide()
}
C.showMenu(s.nsStatusItem, s.nsMenu)
return
}
if s.parent.attachedWindow.Window != nil {
// If we have an attached window, then we need to hide it
s.parent.attachedWindow.Window.Hide()
s.parent.defaultClickHandler()
}
C.showMenu(s.nsStatusItem, s.nsMenu)
}
}