MCPcopy
hub / github.com/g3n/engine / AddMenu

Method AddMenu

gui/menu.go:188–208  ·  view source on GitHub ↗

AddMenu creates and adds a new menu item to this menu with the specified text and sub menu. Returns the pointer to the created menu item.

(text string, subm *Menu)

Source from the content-addressed store, hash-verified

186// specified text and sub menu.
187// Returns the pointer to the created menu item.
188func (m *Menu) AddMenu(text string, subm *Menu) *MenuItem {
189
190 mi := newMenuItem(text, m.styles.Item)
191 mi.zLayerDelta = 1
192 m.Panel.Add(mi)
193 m.items = append(m.items, mi)
194 mi.submenu = subm
195 mi.submenu.SetVisible(false)
196 mi.submenu.SetBounded(false)
197 mi.submenu.mitem = mi
198 mi.submenu.autoOpen = true
199 mi.menu = m
200 if !m.bar {
201 mi.ricon = NewIcon(string(icon.PlayArrow))
202 mi.Panel.Add(mi.ricon)
203 }
204 mi.Panel.Add(mi.submenu)
205 mi.update()
206 m.recalc()
207 return mi
208}
209
210// RemoveItem removes the specified menu item from this menu
211func (m *Menu) RemoveItem(mi *MenuItem) {

Callers 1

buildMenuFunction · 0.95

Calls 7

recalcMethod · 0.95
newMenuItemFunction · 0.85
NewIconFunction · 0.85
SetBoundedMethod · 0.80
SetVisibleMethod · 0.65
AddMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected