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

Show() does not restore or display sub menu items on Windows. #218

Closed
davidnewhall opened this issue Dec 22, 2021 · 2 comments
Closed

Show() does not restore or display sub menu items on Windows. #218

davidnewhall opened this issue Dec 22, 2021 · 2 comments

Comments

@davidnewhall
Copy link

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
Copy link
Author

Confirmed #204 fixes this.

@Crosse
Copy link
Contributor

Crosse commented Feb 22, 2022

I just merged #204, so this should be fixed now.

@Crosse Crosse closed this as completed Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants