Support Hidden attribute. Add SetTooltip & SetIcons to SystemTray. Add Show & Hide to menuItem

This commit is contained in:
Lea Anthony 2022-10-08 07:45:29 +11:00
commit 5fab671af3
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
3 changed files with 31 additions and 0 deletions

View file

@ -16,6 +16,9 @@ type PopupMenu struct {
func (p *PopupMenu) buildMenu(parentMenu win32.PopupMenu, inputMenu *menu.Menu, startindex int) error {
for index, item := range inputMenu.Items {
if item.Hidden {
continue
}
var ret bool
itemID := index + startindex
flags := win32.MF_STRING

View file

@ -77,3 +77,21 @@ func (t *SystemTray) Update() error {
}
return nil
}
func (t *SystemTray) SetTooltip(s string) {
if t.impl != nil {
t.impl.SetTooltip(s)
} else {
t.tooltip = s
}
}
func (t *SystemTray) SetIcons(lightModeIcon *options.SystemTrayIcon, darkModeIcon *options.SystemTrayIcon) {
if t.impl != nil {
t.impl.SetIcons(lightModeIcon, darkModeIcon)
} else {
t.lightModeIcon = lightModeIcon
t.darkModeIcon = darkModeIcon
}
}

View file

@ -257,6 +257,16 @@ func (m *MenuItem) SetChecked(value bool) *MenuItem {
return m
}
func (m *MenuItem) Hide() *MenuItem {
m.Hidden = true
return m
}
func (m *MenuItem) Show() *MenuItem {
m.Hidden = false
return m
}
func Label(label string) *MenuItem {
return &MenuItem{
Type: TextType,