mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-16 17:09:28 +08:00
[v3 windows] Rename systray callback handlers
This commit is contained in:
parent
46a0d467c0
commit
6dd092c7a9
@ -17,6 +17,8 @@ func main() {
|
||||
},
|
||||
})
|
||||
|
||||
window := app.NewWebviewWindow().Hide()
|
||||
|
||||
systemTray := app.NewSystemTray()
|
||||
if runtime.GOOS == "darwin" {
|
||||
systemTray.SetIcon(application.DefaultMacTemplateIcon)
|
||||
@ -37,6 +39,10 @@ func main() {
|
||||
|
||||
systemTray.SetMenu(myMenu)
|
||||
|
||||
systemTray.OnClick(func() {
|
||||
window.Show()
|
||||
})
|
||||
|
||||
err := app.Run()
|
||||
|
||||
if err != nil {
|
||||
|
@ -32,12 +32,12 @@ type SystemTray struct {
|
||||
darkModeIcon []byte
|
||||
iconPosition int
|
||||
|
||||
leftButtonClickHandler func()
|
||||
rightButtonClickHandler func()
|
||||
leftButtonDoubleClickHandler func()
|
||||
rightButtonDoubleClickHandler func()
|
||||
mouseEnterHandler func()
|
||||
mouseLeaveHandler func()
|
||||
clickHandler func()
|
||||
rightClickHandler func()
|
||||
doubleClickHandler func()
|
||||
rightDoubleClickHandler func()
|
||||
mouseEnterHandler func()
|
||||
mouseLeaveHandler func()
|
||||
|
||||
// Platform specific implementation
|
||||
impl systemTrayImpl
|
||||
@ -136,23 +136,23 @@ func (s *SystemTray) Destroy() {
|
||||
s.impl.destroy()
|
||||
}
|
||||
|
||||
func (s *SystemTray) OnLeftButtonClick(handler func()) *SystemTray {
|
||||
s.leftButtonClickHandler = handler
|
||||
func (s *SystemTray) OnClick(handler func()) *SystemTray {
|
||||
s.clickHandler = handler
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SystemTray) OnRightButtonClick(handler func()) *SystemTray {
|
||||
s.rightButtonClickHandler = handler
|
||||
func (s *SystemTray) OnRightClick(handler func()) *SystemTray {
|
||||
s.rightClickHandler = handler
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SystemTray) OnLeftButtonDoubleClick(handler func()) *SystemTray {
|
||||
s.leftButtonDoubleClickHandler = handler
|
||||
func (s *SystemTray) OnDoubleClick(handler func()) *SystemTray {
|
||||
s.doubleClickHandler = handler
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SystemTray) OnRightButtonDoubleClick(handler func()) *SystemTray {
|
||||
s.rightButtonDoubleClickHandler = handler
|
||||
func (s *SystemTray) OnRightDoubleClick(handler func()) *SystemTray {
|
||||
s.rightDoubleClickHandler = handler
|
||||
return s
|
||||
}
|
||||
|
||||
|
@ -84,8 +84,15 @@ func (s *windowsSystemTray) run() {
|
||||
// TODO: Set Menu
|
||||
|
||||
// Set Default Callbacks
|
||||
s.parent.leftButtonClickHandler = func() {
|
||||
println("Left Button Clicked")
|
||||
if s.parent.clickHandler == nil {
|
||||
s.parent.clickHandler = func() {
|
||||
println("Left Button Clicked")
|
||||
}
|
||||
}
|
||||
if s.parent.rightClickHandler == nil {
|
||||
s.parent.rightClickHandler = func() {
|
||||
//s.showMenu()
|
||||
}
|
||||
}
|
||||
|
||||
// Update the icon
|
||||
@ -176,20 +183,20 @@ func (s *windowsSystemTray) wndProc(msg uint32, wParam, lParam uintptr) uintptr
|
||||
msg := lParam & 0xffff
|
||||
switch msg {
|
||||
case w32.WM_LBUTTONUP:
|
||||
if s.parent.leftButtonClickHandler != nil {
|
||||
s.parent.leftButtonClickHandler()
|
||||
if s.parent.clickHandler != nil {
|
||||
s.parent.clickHandler()
|
||||
}
|
||||
case w32.WM_RBUTTONUP:
|
||||
if s.parent.rightButtonClickHandler != nil {
|
||||
s.parent.rightButtonClickHandler()
|
||||
if s.parent.rightClickHandler != nil {
|
||||
s.parent.rightClickHandler()
|
||||
}
|
||||
case w32.WM_LBUTTONDBLCLK:
|
||||
if s.parent.leftButtonDoubleClickHandler != nil {
|
||||
s.parent.leftButtonDoubleClickHandler()
|
||||
if s.parent.doubleClickHandler != nil {
|
||||
s.parent.doubleClickHandler()
|
||||
}
|
||||
case w32.WM_RBUTTONDBLCLK:
|
||||
if s.parent.rightButtonDoubleClickHandler != nil {
|
||||
s.parent.rightButtonDoubleClickHandler()
|
||||
if s.parent.rightDoubleClickHandler != nil {
|
||||
s.parent.rightDoubleClickHandler()
|
||||
}
|
||||
case 0x0406:
|
||||
if s.parent.mouseEnterHandler != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user