Documentation
¶
Overview ¶
Package menu provides all the functions and structs related to menus in a Wails application. Heavily inspired by Electron (c) 2013-2020 Github Inc. Electron License: https://github.com/electron/electron/blob/master/LICENSE
Index ¶
- type Callback
- type CallbackData
- type ContextMenu
- type Menu
- type MenuItem
- func Checkbox(label string, checked bool, accelerator *keys.Accelerator, click Callback) *MenuItem
- func Radio(label string, selected bool, accelerator *keys.Accelerator, click Callback) *MenuItem
- func Separator() *MenuItem
- func SubMenu(label string, menu *Menu) *MenuItem
- func SubMenuWithID(label string, menu *Menu) *MenuItem
- func Text(label string, accelerator *keys.Accelerator, click Callback) *MenuItem
- type TrayMenu
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback func(*CallbackData)
type CallbackData ¶
type CallbackData struct {
MenuItem *MenuItem
}
type ContextMenu ¶
func NewContextMenu ¶
func NewContextMenu(ID string, menu *Menu) *ContextMenu
type Menu ¶
type Menu struct {
Items []*MenuItem
}
func NewMenuFromItems ¶
type MenuItem ¶
type MenuItem struct {
// Label is what appears as the menu text
Label string
// Role is a predefined menu type
//Role Role `json:"Role,omitempty"`
// Accelerator holds a representation of a key binding
Accelerator *keys.Accelerator `json:"Accelerator,omitempty"`
// Type of MenuItem, EG: Checkbox, Text, Separator, Radio, Submenu
Type Type
// Disabled makes the item unselectable
Disabled bool
// Hidden ensures that the item is not shown in the menu
Hidden bool
// Checked indicates if the item is selected (used by Checkbox and Radio types only)
Checked bool
// Submenu contains a list of menu items that will be shown as a submenu
//SubMenu []*MenuItem `json:"SubMenu,omitempty"`
SubMenu *Menu `json:"SubMenu,omitempty"`
// Callback function when menu clicked
Click Callback `json:"-"`
// contains filtered or unexported fields
}
MenuItem represents a menuitem contained in a menu
func SubMenuWithID ¶
SubMenuWithID is a helper to create Submenus with an ID
func Text ¶
func Text(label string, accelerator *keys.Accelerator, click Callback) *MenuItem
Text is a helper to create basic Text menu items
func (*MenuItem) Append ¶
Append will attempt to append the given menu item to this item's submenu items. If this menu item is not a submenu, then this method will not add the item and simply return false.
func (*MenuItem) InsertAfter ¶
InsertAfter attempts to add the given item after this item in the parent menu. If there is no parent menu (we are a top level menu) then false is returned
func (*MenuItem) InsertBefore ¶
InsertBefore attempts to add the given item before this item in the parent menu. If there is no parent menu (we are a top level menu) then false is returned
func (*MenuItem) Parent ¶
Parent returns the parent of the menu item. If it is a top level menu then it returns nil.
type TrayMenu ¶
type TrayMenu struct {
// Label is the text we wish to display in the tray
Label string
// Image is the name of the tray icon we wish to display.
// These are read up during build from <projectdir>/trayicons and
// the filenames are used as IDs, minus the extension
// EG: <projectdir>/trayicons/main.png can be referenced here with "main"
// If the image is not a filename, it will be treated as base64 image data
Image string
// MacTemplateImage indicates that on a Mac, this image is a template image
MacTemplateImage bool
// Text Colour
RGBA string
// Font
FontSize int
FontName string
// Tooltip
Tooltip string
// Disabled makes the item unselectable
Disabled bool
// Menu is the initial menu we wish to use for the tray
Menu *Menu
// OnOpen is called when the Menu is opened
OnOpen func()
// OnClose is called when the Menu is closed
OnClose func()
}
TrayMenu are the options
type Type ¶
type Type string
Type of the menu item
const ( // TextType is the text menuitem type TextType Type = "Text" // SeparatorType is the Separator menuitem type SeparatorType Type = "Separator" SubmenuType Type = "Submenu" // CheckboxType is the Checkbox menuitem type CheckboxType Type = "Checkbox" // RadioType is the Radio menuitem type RadioType Type = "Radio" )