MCPcopy Create free account
hub / github.com/cogentcore/core / applyContextMenus

Method applyContextMenus

core/menu.go:137–152  ·  view source on GitHub ↗

applyContextMenus adds the [Widget.ContextMenus] to the given menu scene in reverse order. It also adds separators between each context menu function.

(m *Scene)

Source from the content-addressed store, hash-verified

135// applyContextMenus adds the [Widget.ContextMenus] to the given menu scene
136// in reverse order. It also adds separators between each context menu function.
137func (wb *WidgetBase) applyContextMenus(m *Scene) {
138 for i := len(wb.ContextMenus) - 1; i >= 0; i-- {
139 wb.ContextMenus[i](m)
140
141 nc := m.NumChildren()
142 // we delete any extra separator
143 if nc > 0 {
144 if _, ok := m.Child(nc - 1).(*Separator); ok {
145 m.DeleteChildAt(nc - 1)
146 }
147 }
148 if i != 0 {
149 NewSeparator(m)
150 }
151 }
152}
153
154// ContextMenuPos returns the default position for the context menu
155// upper left corner. The event will be from a mouse ContextMenu

Callers

nothing calls this directly

Calls 4

NewSeparatorFunction · 0.85
NumChildrenMethod · 0.80
ChildMethod · 0.80
DeleteChildAtMethod · 0.80

Tested by

no test coverage detected