Show() does not restore or display sub menu items on Windows.
davidnewhall opened this issue · 2 comments
davidnewhall commented
When running .Show() on menu item with sub menu items, the sub menu items do not appear. I'm not real sure how to work around this. Ideas?
This reproduces the issue:
package main
import (
"time"
"github.com/getlantern/systray"
)
func main() {
systray.Run(func() {
time.Sleep(time.Second)
systray.AddMenuItem("Menu", "Main Menu")
sub := systray.AddMenuItem("Submenu", "Main Menu")
sub.AddSubMenuItem("Item1", "item 1")
sub.Hide()
sub.Show()
}, nil)
}
If you remove the sub.Hide()
line then the sub menu item appears; otherwise, it does not. macOS does not have this problem, and I did not test on Linux. If you remove the sleep, then the library throws panics about Invalid menu items. The changes in #206 did not solve the errors. These are the errors generated when the time.Sleep()
is removed:
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.(*MenuItem).update (systray.go:220)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.AddMenuItem (systray.go:119)
ERROR systray: systray_windows.go:908 at main.main.func1 (main.go:9)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.Register.func2 (systray.go:94)
ERROR systray: systray_windows.go:908 at runtime.goexit (asm_amd64.s:1581)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.(*MenuItem).update (systray.go:220)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.AddMenuItem (systray.go:119)
ERROR systray: systray_windows.go:908 at main.main.func1 (main.go:10)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.Register.func2 (systray.go:94)
ERROR systray: systray_windows.go:908 at runtime.goexit (asm_amd64.s:1581)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.(*MenuItem).update (systray.go:220)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.(*MenuItem).AddSubMenuItem (systray.go:144)
ERROR systray: systray_windows.go:908 at main.main.func1 (main.go:11)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.Register.func2 (systray.go:94)
ERROR systray: systray_windows.go:908 at runtime.goexit (asm_amd64.s:1581)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:932 Unable to hideMenuItem: Invalid menu handle. [error=Unable to hideMenuItem: %v error_location=github.com/getlantern/systray.hideMenuItem (systray_windows.go:932) error_text=Unable to hideMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:932 at github.com/getlantern/systray.hideMenuItem (systray_windows.go:932)
ERROR systray: systray_windows.go:932 at github.com/getlantern/systray.(*MenuItem).Hide (systray.go:190)
ERROR systray: systray_windows.go:932 at main.main.func1 (main.go:12)
ERROR systray: systray_windows.go:932 at github.com/getlantern/systray.Register.func2 (systray.go:94)
ERROR systray: systray_windows.go:932 at runtime.goexit (asm_amd64.s:1581)
ERROR systray: systray_windows.go:932 Caused by: Invalid menu handle.
ERROR systray: systray_windows.go:908 Unable to addOrUpdateMenuItem: Invalid menu handle. [error=Unable to addOrUpdateMenuItem: %v error_location=github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908) error_text=Unable to addOrUpdateMenuItem: Invalid menu handle. error_type=errors.Error]
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.addOrUpdateMenuItem (systray_windows.go:908)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.showMenuItem (systray_windows.go:938)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.(*MenuItem).Show (systray.go:195)
ERROR systray: systray_windows.go:908 at main.main.func1 (main.go:13)
ERROR systray: systray_windows.go:908 at github.com/getlantern/systray.Register.func2 (systray.go:94)
ERROR systray: systray_windows.go:908 at runtime.goexit (asm_amd64.s:1581)
ERROR systray: systray_windows.go:908 Caused by: Invalid menu handle.
davidnewhall commented
Confirmed #204 fixes this.