Documentation
¶
Index ¶
- func BarHeight() float64
- func CloseKeyWindowHandler(item *Item)
- func CloseKeyWindowValidator(item *Item) bool
- func InsertCloseKeyWindowItem(menu *Menu, atIndex int)
- func InsertMinimizeItem(menu *Menu, atIndex int)
- func InsertQuitItem(menu *Menu, atIndex int)
- func InsertZoomItem(menu *Menu, atIndex int)
- func MinimizeHandler(item *Item)
- func MinimizeValidator(item *Item) bool
- func ZoomHandler(item *Item)
- func ZoomValidator(item *Item) bool
- type Bar
- func (bar *Bar) Count() int
- func (bar *Bar) IndexOf(menu *Menu) int
- func (bar *Bar) InsertMenu(atIndex, id int, menu *Menu)
- func (bar *Bar) InsertStdMenus(aboutHandler, prefsHandler ItemHandler, updater Updater)
- func (bar *Bar) Menu(id int) *Menu
- func (bar *Bar) MenuAtIndex(index int) *Menu
- func (bar *Bar) MenuItem(id int) *Item
- func (bar *Bar) Remove(index int)
- type Item
- func (item *Item) CheckState() state.State
- func (item *Item) ID() int
- func (item *Item) Index() int
- func (item *Item) IsSame(other *Item) bool
- func (item *Item) IsSeparator() bool
- func (item *Item) Menu() *Menu
- func (item *Item) SetCheckState(s state.State)
- func (item *Item) SetTitle(title string)
- func (item *Item) SubMenu() *Menu
- func (item *Item) Title() string
- type ItemHandler
- type ItemValidator
- type Menu
- func New(title string, updater Updater) *Menu
- func NewAppMenu(aboutHandler, prefsHandler ItemHandler, updater Updater) *Menu
- func NewEditMenu(prefsHandler ItemHandler, updater Updater) *Menu
- func NewFileMenu(updater Updater) *Menu
- func NewHelpMenu(aboutHandler ItemHandler, updater Updater) *Menu
- func NewWindowMenu(updater Updater) *Menu
- func (menu *Menu) Count() int
- func (menu *Menu) Dispose()
- func (menu *Menu) InsertActionItem(atIndex int, cmd action.Action) *Item
- func (menu *Menu) InsertActionItemForContextMenu(atIndex int, cmd action.Action) *Item
- func (menu *Menu) InsertItem(atIndex, id int, title string, key *keys.Key, keyModifiers keys.Modifiers, ...) *Item
- func (menu *Menu) InsertMenu(atIndex, id int, title string, updater Updater) *Menu
- func (menu *Menu) InsertSeparator(atIndex int)
- func (menu *Menu) InsertSeparatorIfNeeded(atIndex int)
- func (menu *Menu) IsSame(other *Menu) bool
- func (menu *Menu) Item(id int) *Item
- func (menu *Menu) ItemAtIndex(index int) *Item
- func (menu *Menu) Popup(wnd *ux.Window, where geom.Rect, currentIndex int)
- func (menu *Menu) RemoveItem(index int)
- type Updater
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 ¶
CloseKeyWindowValidator provides the standard validation function for the "Close" menu.
func InsertCloseKeyWindowItem ¶
InsertCloseKeyWindowItem creates the standard "Close" menu item that will close the current key window when chosen.
func InsertMinimizeItem ¶
InsertMinimizeItem creates the standard "Minimize" menu item that will issue the Minimize command to the current key window when chosen.
func InsertQuitItem ¶
InsertQuitItem creates the standard "Quit"/"Exit" menu item that will issue the Quit command when chosen.
func InsertZoomItem ¶
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 ¶
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 ¶
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 ¶
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) InsertMenu ¶
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 ¶
Menu returns the menu with the specified id anywhere in the menu bar and its sub-menus.
func (*Bar) MenuAtIndex ¶
MenuAtIndex returns the menu at the specified index within the menu bar.
type Item ¶
type Item struct {
// contains filtered or unexported fields
}
Item holds information about menu items.
func (*Item) CheckState ¶
CheckState returns the item's current check state.
func (*Item) Index ¶
Index returns the index of the item within its menu. Returns -1 if it is not yet attached to a menu.
func (*Item) IsSame ¶
IsSame returns true if the two items represent the same object. Do not use == to test for equality.
func (*Item) IsSeparator ¶
IsSeparator returns true if this item is a separator.
func (*Item) SetCheckState ¶
SetCheckState sets the item's check state.
type ItemHandler ¶
type ItemHandler func(item *Item)
ItemHandler is a function called to handle a menu item that was selected.
type ItemValidator ¶
ItemValidator is a function called to validate a menu item.
type Menu ¶
type Menu struct {
// contains filtered or unexported fields
}
Menu represents a set of menu items.
func New ¶
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 ¶
NewFileMenu creates a standard 'File' menu.
func NewHelpMenu ¶
func NewHelpMenu(aboutHandler ItemHandler, updater Updater) *Menu
NewHelpMenu creates a standard 'Help' menu.
func NewWindowMenu ¶
NewWindowMenu creates a standard 'Window' menu.
func (*Menu) Dispose ¶
func (menu *Menu) Dispose()
Dispose releases any OS resources associated with this menu.
func (*Menu) InsertActionItem ¶
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) InsertActionItemForContextMenu ¶
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) InsertItem ¶
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) InsertMenu ¶
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) InsertSeparator ¶
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) InsertSeparatorIfNeeded ¶
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) IsSame ¶
IsSame returns true if the two menus represent the same object. Do not use == to test for equality.
func (*Menu) Item ¶
Item returns the menu item with the specified id anywhere in the menu and and its sub-menus.
func (*Menu) ItemAtIndex ¶
ItemAtIndex returns the menu item at the specified index within the menu.
func (*Menu) RemoveItem ¶
RemoveItem removes the menu item at the specified index from this menu.