Skip to content

fn create #

fn create(icon_path string, opts CreatOptions) &Tray

create creates the tray.
On macOS, the tray icon size must be 22x22 pixels to be rendered correctly.

struct CreatOptions #

struct CreatOptions {
	identifier string = 'VTray'
	tooltip    string
}

struct Tray #

struct Tray {
mut:
	instance   &VTray = unsafe { nil }
	icon       string
	identifier string
	tooltip    string
	items      []&MenuItem
	callbacks  map[int]ItemCallback
	last_id    int = 1
}

Tray is the main struct that represents the tray app.

fn (Tray) add_item #

fn (mut t Tray) add_item(text string, opts MenuItemOptions)

add_item adds an item to the tray.

fn (Tray) set_icon #

fn (t &Tray) set_icon(icon string)

set_icon sets the tray icon.

fn (Tray) set_tooltip #

fn (t &Tray) set_tooltip(tooltip string)

set_tooltip sets the tray tooltip.

fn (Tray) get_item #

fn (t &Tray) get_item(item string) ?&MenuItem

get_item returns the menu item with the given text.

fn (Tray) run #

fn (mut t Tray) run()

run runs the tray app.

fn (Tray) destroy #

fn (t &Tray) destroy()

destroy destroys the tray app and frees allocated memory.