newMenuItem creates and returns a pointer to a new menu item with the specified text.
(text string, styles *MenuItemStyles)
| 558 | // newMenuItem creates and returns a pointer to a new menu item |
| 559 | // with the specified text. |
| 560 | func 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 |
no test coverage detected