10
menuitem.go
10
menuitem.go
@@ -20,10 +20,15 @@ type MenuItem struct {
|
||||
|
||||
// NewMenuItem creates a new menu item with the specified text.
|
||||
func NewMenuItem (text string) *MenuItem {
|
||||
return NewIconMenuItem(tomo.IconUnknown, text)
|
||||
}
|
||||
|
||||
// NewIconMenuItem creates a new menu item with the specified icon and text.
|
||||
func NewIconMenuItem (icon tomo.Icon, text string) *MenuItem {
|
||||
box := &MenuItem {
|
||||
ContainerBox: tomo.NewContainerBox(),
|
||||
label: NewLabel(text),
|
||||
icon: NewIcon("", tomo.IconSizeSmall),
|
||||
icon: NewIcon(icon, tomo.IconSizeSmall),
|
||||
}
|
||||
box.SetRole(tomo.R("objects", "MenuItem"))
|
||||
box.label.SetAttr(tomo.AAlign(tomo.AlignStart, tomo.AlignMiddle))
|
||||
@@ -49,8 +54,7 @@ func (this *MenuItem) SetText (text string) {
|
||||
// SetIcon sets an icon for this item. Setting the icon to IconUnknown will
|
||||
// remove it.
|
||||
func (this *MenuItem) SetIcon (id tomo.Icon) {
|
||||
if this.icon != nil { this.Remove(this.icon) }
|
||||
this.Insert(NewIcon(id, tomo.IconSizeSmall), this.label)
|
||||
this.icon.SetIcon(id, tomo.IconSizeSmall)
|
||||
}
|
||||
|
||||
// OnClick specifies a function to be called when the menu item is clicked.
|
||||
|
||||
Reference in New Issue
Block a user