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

Function newMenuItem

gui/menu.go:560–574  ·  view source on GitHub ↗

newMenuItem creates and returns a pointer to a new menu item with the specified text.

(text string, styles *MenuItemStyles)

Source from the content-addressed store, hash-verified

558// newMenuItem creates and returns a pointer to a new menu item
559// with the specified text.
560func newMenuItem(text string, styles *MenuItemStyles) *MenuItem {
561
562 mi := new(MenuItem)
563 mi.Panel.Initialize(mi, 0, 0)
564 mi.styles = styles
565 if text != "" {
566 mi.label = NewLabel(text)
567 mi.Panel.Add(mi.label)
568 mi.Panel.Subscribe(OnCursorEnter, mi.onCursor)
569 mi.Panel.Subscribe(OnCursor, mi.onCursor)
570 mi.Panel.Subscribe(OnMouseDown, mi.onMouse)
571 }
572 mi.update()
573 return mi
574}
575
576// SetIcon sets the left icon of this menu item
577// If an image was previously set it is replaced by this icon

Callers 3

AddOptionMethod · 0.85
AddSeparatorMethod · 0.85
AddMenuMethod · 0.85

Calls 5

NewLabelFunction · 0.85
SubscribeMethod · 0.65
InitializeMethod · 0.45
AddMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected