type ContextMenu struct {
// contains filtered or unexported fields
}
ContextMenu paints an application-positioned menu without owning pointer,
keyboard, or popup lifecycle state. PlaceOverlay, given a zero-size anchor at
the pointer, places it with the flip a context menu needs next to a window edge.
Methods
AddItem#
func (menu *ContextMenu) AddItem(item ContextMenuItem) ui.Rect
AddItem paints one action, checkbox, radio option, or submenu trigger. The
rectangle is empty when the row is scrolled out of the menu.
AddItemSlot#
func (menu *ContextMenu) AddItemSlot(item ContextMenuItem) (row, slot ui.Rect)
AddItemSlot paints an item like AddItem and also returns the rectangle its
TrailingWidth reserved, vertically centered in the row and ending 8px from its
edge. The slot is empty when the item has no TrailingWidth or is scrolled out
of the menu. Paint into it between BeginContent and EndContent.
AddLabel#
func (menu *ContextMenu) AddLabel(label string, inset bool) ui.Rect
AddLabel paints one medium-weight group label and returns its row geometry.
AddSeparator#
func (menu *ContextMenu) AddSeparator() ui.Rect
AddSeparator paints the official -mx-1/my-1 divider geometry.
BeginContent#
func (menu *ContextMenu) BeginContent()
BeginContent enters the menu's layer and focus scope so the caller's own
components, painted until EndContent, belong to the menu: above the page, inside
its focus trap, and hit-tested over the row beneath.
Bounds#
func (menu ContextMenu) Bounds() ui.Rect
Bounds returns the normalized overlay geometry.
End#
func (menu *ContextMenu) End()
End paints the scrollbar of a menu whose items did not all fit, after the last
item: call it once the last item is painted.
EndContent#
func (menu *ContextMenu) EndContent()
EndContent leaves the layer and focus scope BeginContent entered.
NextItemBounds#
func (menu ContextMenu) NextItemBounds() ui.Rect
NextItemBounds returns the next keyboard-navigation row (RowHeight high)
without advancing the declaration cursor.