systray

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

Source code in the current directory are ported from https://github.com/getlantern/systray and make more changes.

Thanks the original authors.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMenuItem

func AddMenuItem(parent, item *MenuItem)

AddMenuItem appends the item to the parent menu list.

func AddMenuItemBefore

func AddMenuItemBefore(parent, item *MenuItem, next *MenuItem)

AddMenuItemBefore adds the item to the parent menu list before the specified next item.

func Events

func Events() <-chan *MenuItem

Events returns the events list.

func Quit

func Quit()

Quit the systray

func Register

func Register(onReady func(), onExit func())

Register initializes GUI and registers the callbacks but relies on the caller to run the event loop somewhere else. It's useful if the program needs to show other UI elements, for example, webview. To overcome some OS weirdness, On macOS versions before Catalina, calling this does exactly the same as Run().

func Run

func Run(onReady func(), onExit func())

Run initializes GUI and starts the event loop, then invokes the onReady callback. It blocks until systray.Quit() is called.

func SetIcon

func SetIcon(iconBytes []byte)

SetIcon sets the systray icon. iconBytes should be the content of .ico for windows and .ico/.jpg/.png for other platforms.

func SetTitle

func SetTitle(title string)

SetTitle sets the systray title, only available on Mac and Linux.

Types

type Action

type Action func()
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 the one systray.AddMenuItem() returned

func NewMenuItem

func NewMenuItem(title string) *MenuItem

NewMenuItem returns a MenuItem object with the specified title.

func NewSeparator

func NewSeparator() *MenuItem

NewSeparator returns a separator without title.

func (item *MenuItem) Action() Action

Action returns the event handler action.

func (item *MenuItem) Children() []*MenuItem
func (item *MenuItem) RemoveAllItems()
func (item *MenuItem) SetAction(action Action)

SetAction sets the event handler action.

func (item *MenuItem) SetChecked(checked bool)

SetChecked sets the checked status of the current menu item.

func (item *MenuItem) SetDisabled(disabled bool)

SetDisabled sets enable status of the current menu item.

func (item *MenuItem) SetHidden(hidden bool)

SetHidden sets the hidden status of the current menu item.

func (item *MenuItem) SetTitle(title string)

SetTitle set the text to display on a menu item

func (item *MenuItem) String() string

String implements the fmt.Stringer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL