Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callback for popup menu open/close in Windows #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions systray.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ import (
var (
log = golog.LoggerFor("systray")

// MenuOpenedCh is the channel which will be notified when the popup menu is shown
MenuOpenedCh = make(chan struct{})

// MenuClosedCh is the channel which will be notified when the popup menu is closed
MenuClosedCh = make(chan struct{})

systrayReady func()
systrayExit func()
menuItems = make(map[int32]*MenuItem)
Expand Down
10 changes: 10 additions & 0 deletions systray_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,11 @@ func (t *winTray) hideMenuItem(menuItemId, parentId uint32) error {
}

func (t *winTray) showMenu() error {
select {
case MenuOpenedCh <- struct{}{}:
default:
}

const (
TPM_BOTTOMALIGN = 0x0020
TPM_LEFTALIGN = 0x0000
Expand All @@ -623,6 +628,11 @@ func (t *winTray) showMenu() error {
return err
}

select {
case MenuClosedCh <- struct{}{}:
default:
}

return nil
}

Expand Down