menu

package
v0.0.0-...-955f326 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BarHeight

func BarHeight() float64

BarHeight returns the height of the Bar when displayed in a window.

func CloseKeyWindowHandler

func CloseKeyWindowHandler(item *Item)

CloseKeyWindowHandler provides the standard handler function for the "Close" menu.

func CloseKeyWindowValidator

func CloseKeyWindowValidator(item *Item) bool

CloseKeyWindowValidator provides the standard validation function for the "Close" menu.

func InsertCloseKeyWindowItem

func InsertCloseKeyWindowItem(menu *Menu, atIndex int)

InsertCloseKeyWindowItem creates the standard "Close" menu item that will close the current key window when chosen.

func InsertMinimizeItem

func InsertMinimizeItem(menu *Menu, atIndex int)

InsertMinimizeItem creates the standard "Minimize" menu item that will issue the Minimize command to the current key window when chosen.

func InsertQuitItem

func InsertQuitItem(menu *Menu, atIndex int)

InsertQuitItem creates the standard "Quit"/"Exit" menu item that will issue the Quit command when chosen.

func InsertZoomItem

func InsertZoomItem(menu *Menu, atIndex int)

InsertZoomItem creates the standard "Zoom" menu item that will issue the Zoom command to the current key window when chosen.

func MinimizeHandler

func MinimizeHandler(item *Item)

MinimizeHandler provides the standard handler function for the "Minimize" menu item.

func MinimizeValidator

func MinimizeValidator(item *Item) bool

MinimizeValidator provides the standard validation function for the "Minimize" menu item.

func ZoomHandler

func ZoomHandler(item *Item)

ZoomHandler provides the standard handler function for the "Zoom" menu item.

func ZoomValidator

func ZoomValidator(item *Item) bool

ZoomValidator provides the standard validation function for the "Zoom" menu item.

Types

type Bar

type Bar struct {
	// contains filtered or unexported fields
}

Bar represents a set of menus.

func BarForWindow

func BarForWindow(window *ux.Window, updater Updater) (bar *Bar, isGlobal, isFirst bool)

BarForWindow returns the menu bar for the given window. On macOS, the menu bar is a global entity and the same value will be returned for all windows. On macOS, you may pass nil for the window parameter. If isGlobal returns as true, the first time this function is called, isFirst will be returned as true as well, allowing you to only initialize the global menu bar once. 'updater' is optional. If present, it will be called prior to showing a top-level menu, giving a chance to modify that menu.

func (*Bar) Count

func (bar *Bar) Count() int

Count of menus in this menu bar.

func (*Bar) IndexOf

func (bar *Bar) IndexOf(menu *Menu) int

IndexOf returns the index of the menu within this menu bar, or -1.

func (*Bar) InsertMenu

func (bar *Bar) InsertMenu(atIndex, id int, menu *Menu)

InsertMenu inserts a menu at the specified item index within this menu bar. Pass in a negative index to append to the end.

func (*Bar) InsertStdMenus

func (bar *Bar) InsertStdMenus(aboutHandler, prefsHandler ItemHandler, updater Updater)

InsertStdMenus adds the standard menus to the menu bar.

func (*Bar) Menu

func (bar *Bar) Menu(id int) *Menu

Menu returns the menu with the specified id anywhere in the menu bar and its sub-menus.

func (*Bar) MenuAtIndex

func (bar *Bar) MenuAtIndex(index int) *Menu

MenuAtIndex returns the menu at the specified index within the menu bar.

func (*Bar) MenuItem

func (bar *Bar) MenuItem(id int) *Item

MenuItem returns the menu item with the specified id anywhere in the menu bar and its sub-menus.

func (*Bar) Remove

func (bar *Bar) Remove(index int)

Remove the menu at the specified index from this menu bar.

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item holds information about menu items.

func (*Item) CheckState

func (item *Item) CheckState() state.State

CheckState returns the item's current check state.

func (*Item) ID

func (item *Item) ID() int

ID returns the id of this item.

func (*Item) Index

func (item *Item) Index() int

Index returns the index of the item within its menu. Returns -1 if it is not yet attached to a menu.

func (*Item) IsSame

func (item *Item) IsSame(other *Item) bool

IsSame returns true if the two items represent the same object. Do not use == to test for equality.

func (*Item) IsSeparator

func (item *Item) IsSeparator() bool

IsSeparator returns true if this item is a separator.

func (*Item) Menu

func (item *Item) Menu() *Menu

Menu returns the owning menu.

func (*Item) SetCheckState

func (item *Item) SetCheckState(s state.State)

SetCheckState sets the item's check state.

func (*Item) SetTitle

func (item *Item) SetTitle(title string)

SetTitle sets the item's title.

func (*Item) SubMenu

func (item *Item) SubMenu() *Menu

SubMenu returns the item's sub-menu, if any.

func (*Item) Title

func (item *Item) Title() string

Title returns the item's title.

type ItemHandler

type ItemHandler func(item *Item)

ItemHandler is a function called to handle a menu item that was selected.

type ItemValidator

type ItemValidator func(item *Item) bool

ItemValidator is a function called to validate a menu item.

type Menu struct {
	// contains filtered or unexported fields
}

Menu represents a set of menu items.

func New

func New(title string, updater Updater) *Menu

New creates a new menu. 'updater' is optional. If present, it will be called prior to showing the menu, giving a chance to modify the menu.

func NewAppMenu

func NewAppMenu(aboutHandler, prefsHandler ItemHandler, updater Updater) *Menu

NewAppMenu creates a standard 'App' menu. Really only intended for macOS, although other platforms can use it if desired.

func NewEditMenu

func NewEditMenu(prefsHandler ItemHandler, updater Updater) *Menu

NewEditMenu creates a standard 'Edit' menu.

func NewFileMenu

func NewFileMenu(updater Updater) *Menu

NewFileMenu creates a standard 'File' menu.

func NewHelpMenu

func NewHelpMenu(aboutHandler ItemHandler, updater Updater) *Menu

NewHelpMenu creates a standard 'Help' menu.

func NewWindowMenu

func NewWindowMenu(updater Updater) *Menu

NewWindowMenu creates a standard 'Window' menu.

func (menu *Menu) Count() int

Count of menu items in this menu.

func (menu *Menu) Dispose()

Dispose releases any OS resources associated with this menu.

func (menu *Menu) InsertActionItem(atIndex int, cmd action.Action) *Item

InsertActionItem inserts a menu item using the action at the specified item index within this menu. Pass in a negative index to append to the end.

func (menu *Menu) InsertActionItemForContextMenu(atIndex int, cmd action.Action) *Item

InsertActionItemForContextMenu inserts a menu item for a context menu using the action at the specified item index within this menu. Pass in a negative index to append to the end. If the item would be disabled, it is not added and nil is returned.

func (menu *Menu) InsertItem(atIndex, id int, title string, key *keys.Key, keyModifiers keys.Modifiers, validator ItemValidator, handler ItemHandler) *Item

InsertItem inserts a menu item at the specified item index within this menu. Pass in a negative index to append to the end. Both 'validator' and 'handler' may be nil for default behavior.

func (menu *Menu) InsertMenu(atIndex, id int, title string, updater Updater) *Menu

InsertMenu inserts a new sub-menu at the specified item index within this menu. Pass in a negative index to append to the end. 'updater' is optional. If present, it will be called prior to showing the menu, giving a chance to modify the menu.

func (menu *Menu) InsertSeparator(atIndex int)

InsertSeparator inserts a menu separator at the specified item index within this menu. Pass in a negative index to append to the end.

func (menu *Menu) InsertSeparatorIfNeeded(atIndex int)

InsertSeparatorIfNeeded inserts a menu separator at the specified item index within this menu if the item that would precede it is not a separator. Pass in a negative index to append to the end.

func (menu *Menu) IsSame(other *Menu) bool

IsSame returns true if the two menus represent the same object. Do not use == to test for equality.

func (menu *Menu) Item(id int) *Item

Item returns the menu item with the specified id anywhere in the menu and and its sub-menus.

func (menu *Menu) ItemAtIndex(index int) *Item

ItemAtIndex returns the menu item at the specified index within the menu.

func (menu *Menu) Popup(wnd *ux.Window, where geom.Rect, currentIndex int)

Popup the menu at the specified position within the window.

func (menu *Menu) RemoveItem(index int)

RemoveItem removes the menu item at the specified index from this menu.

type Updater

type Updater func(menu *Menu)

Updater is a function called to update a menu before it is shown.

Jump to

Keyboard shortcuts

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