Documentation
¶
Overview ¶
Package wintray is a Windows-specific Go library to place an icon and menu in the notification area.
Index ¶
- Variables
- func AddSeparator()
- func OnTrayOpened(f func())
- func Quit()
- func Register(onReady func(), onExit func()) error
- func ResetMenu()
- func Run(onReady, onExit func()) error
- func RunWithExternalLoop(onReady, onExit func()) (start, end func(), err error)
- func SetIcon(iconBytes []byte) error
- func SetIconFromFilePath(iconFilePath string) error
- func SetOpenOnLeftClick(open bool)
- func SetOpenOnRightClick(open bool)
- func SetTooltip(tooltip string) error
- type MenuItem
- func (item *MenuItem) AddSeparator()
- func (item *MenuItem) AddSubMenuItem(title string) *MenuItem
- func (item *MenuItem) Check()
- func (item *MenuItem) Checked() bool
- func (item *MenuItem) Disable()
- func (item *MenuItem) Disabled() bool
- func (item *MenuItem) Enable()
- func (item *MenuItem) Hide()
- func (item *MenuItem) Remove()
- func (item *MenuItem) SetCallback(onClick func())
- func (item *MenuItem) SetIcon(iconBytes []byte) error
- func (item *MenuItem) SetIconFromFilePath(iconFilePath string) error
- func (item *MenuItem) SetTitle(title string)
- func (item *MenuItem) Show()
- func (item *MenuItem) String() string
- func (item *MenuItem) Uncheck()
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTrayNotReadyYet is returned by functions when they are called before the tray has been initialized. ErrTrayNotReadyYet = errors.New("tray not ready yet") )
Functions ¶
func OnTrayOpened ¶
func OnTrayOpened(f func())
Add a callback to be called when the tray is opened.
func Register ¶
func Register(onReady func(), onExit func()) error
Initializes the GUI and register the callbacks. Relies on the caller to run the event loop somewhere else. Useful if the program needs to show other UI elements.
func Run ¶
func Run(onReady, onExit func()) error
Initialize the GUI and start the event loop, then invoke the onReady callback. Blocks until systray.Quit() is called.
func RunWithExternalLoop ¶
func RunWithExternalLoop(onReady, onExit func()) (start, end func(), err error)
RunWithExternalLoop allows the systemtray module to operate with other tookits. The returned start and end functions should be called by the toolkit when the application has started and will end.
func SetIconFromFilePath ¶
Set the systray icon from a file path. iconFilePath should be the path to a .ico image.
func SetOpenOnLeftClick ¶
func SetOpenOnLeftClick(open bool)
Set whether or not the icon should respond to left clicks. The default is true.
func SetOpenOnRightClick ¶
func SetOpenOnRightClick(open bool)
Set whether or not the icon should respond to right clicks. The default is true.
func SetTooltip ¶
Set the tooltip to display on mouse hover of the tray icon.
Types ¶
type MenuItem ¶
type MenuItem struct {
// contains filtered or unexported fields
}
MenuItem is used to keep track each menu item of systray. Don't create it directly, use systray.AddMenuItem()
func AddMenuItem ¶
Add a menu item with the designated title. Can be safely invoked from different goroutines.
func (*MenuItem) AddSeparator ¶
func (item *MenuItem) AddSeparator()
Add a separator bar to the submenu.
func (*MenuItem) AddSubMenuItem ¶
Add a nested sub-menu item with the designated title. Can be safely invoked from different goroutines.
func (*MenuItem) Check ¶
func (item *MenuItem) Check()
Check a menu item regardless if it's previously checked or not.
func (*MenuItem) Disable ¶
func (item *MenuItem) Disable()
Disable a menu item regardless if it's previously disabled or not.
func (*MenuItem) Enable ¶
func (item *MenuItem) Enable()
Enable a menu item regardless if it's previously enabled or not.
func (*MenuItem) Remove ¶
func (item *MenuItem) Remove()
Remove a menu item and, if it has a submenu, all its children.
func (*MenuItem) SetCallback ¶
func (item *MenuItem) SetCallback(onClick func())
Set the function to be called when the menu item is clicked. The function is called from a new goroutine.
func (*MenuItem) SetIcon ¶
Set the icon of a menu item. iconBytes should be the content of .ico image.
func (*MenuItem) SetIconFromFilePath ¶
Set the icon of a menu item from a file path. iconFilePath should be the path to a .ico image.