mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-17 01:19:29 +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()
|
systemTray := app.NewSystemTray()
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
systemTray.SetIcon(application.DefaultMacTemplateIcon)
|
systemTray.SetIcon(application.DefaultMacTemplateIcon)
|
||||||
@ -37,6 +39,10 @@ func main() {
|
|||||||
|
|
||||||
systemTray.SetMenu(myMenu)
|
systemTray.SetMenu(myMenu)
|
||||||
|
|
||||||
|
systemTray.OnClick(func() {
|
||||||
|
window.Show()
|
||||||
|
})
|
||||||
|
|
||||||
err := app.Run()
|
err := app.Run()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -32,10 +32,10 @@ type SystemTray struct {
|
|||||||
darkModeIcon []byte
|
darkModeIcon []byte
|
||||||
iconPosition int
|
iconPosition int
|
||||||
|
|
||||||
leftButtonClickHandler func()
|
clickHandler func()
|
||||||
rightButtonClickHandler func()
|
rightClickHandler func()
|
||||||
leftButtonDoubleClickHandler func()
|
doubleClickHandler func()
|
||||||
rightButtonDoubleClickHandler func()
|
rightDoubleClickHandler func()
|
||||||
mouseEnterHandler func()
|
mouseEnterHandler func()
|
||||||
mouseLeaveHandler func()
|
mouseLeaveHandler func()
|
||||||
|
|
||||||
@ -136,23 +136,23 @@ func (s *SystemTray) Destroy() {
|
|||||||
s.impl.destroy()
|
s.impl.destroy()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SystemTray) OnLeftButtonClick(handler func()) *SystemTray {
|
func (s *SystemTray) OnClick(handler func()) *SystemTray {
|
||||||
s.leftButtonClickHandler = handler
|
s.clickHandler = handler
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SystemTray) OnRightButtonClick(handler func()) *SystemTray {
|
func (s *SystemTray) OnRightClick(handler func()) *SystemTray {
|
||||||
s.rightButtonClickHandler = handler
|
s.rightClickHandler = handler
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SystemTray) OnLeftButtonDoubleClick(handler func()) *SystemTray {
|
func (s *SystemTray) OnDoubleClick(handler func()) *SystemTray {
|
||||||
s.leftButtonDoubleClickHandler = handler
|
s.doubleClickHandler = handler
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SystemTray) OnRightButtonDoubleClick(handler func()) *SystemTray {
|
func (s *SystemTray) OnRightDoubleClick(handler func()) *SystemTray {
|
||||||
s.rightButtonDoubleClickHandler = handler
|
s.rightDoubleClickHandler = handler
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,9 +84,16 @@ func (s *windowsSystemTray) run() {
|
|||||||
// TODO: Set Menu
|
// TODO: Set Menu
|
||||||
|
|
||||||
// Set Default Callbacks
|
// Set Default Callbacks
|
||||||
s.parent.leftButtonClickHandler = func() {
|
if s.parent.clickHandler == nil {
|
||||||
|
s.parent.clickHandler = func() {
|
||||||
println("Left Button Clicked")
|
println("Left Button Clicked")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if s.parent.rightClickHandler == nil {
|
||||||
|
s.parent.rightClickHandler = func() {
|
||||||
|
//s.showMenu()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update the icon
|
// Update the icon
|
||||||
s.updateIcon()
|
s.updateIcon()
|
||||||
@ -176,20 +183,20 @@ func (s *windowsSystemTray) wndProc(msg uint32, wParam, lParam uintptr) uintptr
|
|||||||
msg := lParam & 0xffff
|
msg := lParam & 0xffff
|
||||||
switch msg {
|
switch msg {
|
||||||
case w32.WM_LBUTTONUP:
|
case w32.WM_LBUTTONUP:
|
||||||
if s.parent.leftButtonClickHandler != nil {
|
if s.parent.clickHandler != nil {
|
||||||
s.parent.leftButtonClickHandler()
|
s.parent.clickHandler()
|
||||||
}
|
}
|
||||||
case w32.WM_RBUTTONUP:
|
case w32.WM_RBUTTONUP:
|
||||||
if s.parent.rightButtonClickHandler != nil {
|
if s.parent.rightClickHandler != nil {
|
||||||
s.parent.rightButtonClickHandler()
|
s.parent.rightClickHandler()
|
||||||
}
|
}
|
||||||
case w32.WM_LBUTTONDBLCLK:
|
case w32.WM_LBUTTONDBLCLK:
|
||||||
if s.parent.leftButtonDoubleClickHandler != nil {
|
if s.parent.doubleClickHandler != nil {
|
||||||
s.parent.leftButtonDoubleClickHandler()
|
s.parent.doubleClickHandler()
|
||||||
}
|
}
|
||||||
case w32.WM_RBUTTONDBLCLK:
|
case w32.WM_RBUTTONDBLCLK:
|
||||||
if s.parent.rightButtonDoubleClickHandler != nil {
|
if s.parent.rightDoubleClickHandler != nil {
|
||||||
s.parent.rightButtonDoubleClickHandler()
|
s.parent.rightDoubleClickHandler()
|
||||||
}
|
}
|
||||||
case 0x0406:
|
case 0x0406:
|
||||||
if s.parent.mouseEnterHandler != nil {
|
if s.parent.mouseEnterHandler != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user