mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[v3 mac] Fix right click. Slight refactor.
This commit is contained in:
@@ -68,11 +68,9 @@ func main() {
|
||||
})
|
||||
|
||||
systemTray.SetMenu(myMenu)
|
||||
|
||||
systemTray.AttachWindow(window).WindowOffset(5)
|
||||
|
||||
err := app.Run()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user