asticode / go-astilectron

Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)
MIT License
4.9k stars 344 forks source link

How to use tray? #348

Closed heary29 closed 2 years ago

heary29 commented 2 years ago

Hello, I am trying to use go-astilectron project to make a gui program, I need to have a tray function, but I did not get how to deal with the tray mouse click, right click and other events when viewing the source code, just like the maximization or minimization of the window, the tray.go file only contains create, destroy, set the picture, please what should I do next to help my needs?

asticode commented 2 years ago

Tray inherits the On method which you can use to react to tray's events.

For instance:

var t *astilectron.Tray
t.On(astilectron.EventNameTrayEventClicked, func(e astilectron.Event) (deleteListener bool) {
  log.Println("tray has been clicked!")
  return true
})
heary29 commented 2 years ago

Okay, thank you very much!