Class zebkit.ui.MenuItem
extends <zebkit.ui.Panel>

Menu item panel class. The component holds menu item content like caption, icon, sub-menu sign elements. The area of the component is split into three parts: left, right and center. Central part keeps content, left side keeps checked sign element and the right side keeps sub-menu sign element.

zebkit.ui.MenuItem (content)

  • content <String | zebkit.ui.Panel>

    a menu item content string or component. Caption string can encode the item id, item icon and item checked state. For instance:

            content:  "Test" | {zebkit.ui.Panel}
            checked:  {Boolean},                   // optional
            group  :  {zebkit.ui.Group},           // optional
            icon   :  "path/to/image" | {Image},   // optional
            handler:  {Function}                   // optional
            id     :  {String}                     // optional

// create menu item with icon and "Item 1" title
var mi = new zebkit.ui.MenuItem({
    content: "Menu item label"

Inherited methods:
$setConstraints(c)    add(constr, d)    byConstraints([p], c)    byPath(path, [cb])    calcPreferredSize(target)    doLayout( )    fire(event, [path], [params])    focused( )    getBottom( )    getCanvas( )    getComponentAt(x, y)    getHorPadding( )    getLeft( )    getPreferredSize( )    getRight( )    getTop( )    getVerPadding( )    hasFocus( )    indexOf(c)    insert(i, constr, d)    invalidate( )    invalidateLayout( )    kidAdded(index, constr, l)    kidRemoved(i, l)    laidout( )    load(JSON)    off([eventName], [path], [cb])    on([eventName], [path], cb)    paintComponent(g)    paintViewAt(g, ax, ay, v)    properties([path], props)    property([path], name, value)    recalc( )    relocated(px, py)    remove(c)    removeAll( )    removeAt(i)    removeByConstraints(ctr)    removeMe([after])    repaint([x], [y], [w], [h])    requestFocus( )    requestFocusIn([timeout])    resized(pw, ph)    setAt(i, d)    setBackground(v)    setBorder([v])    setBottomPadding(bottom)    setBounds(x, y, w, h)    setByConstraints(constr, c)    setConstraints(ctr)    setEnabled(b)    setId(id)    setKids(a)    setLayout(m)    setLeftPadding(left)    setLocation(xx, yy)    setPadding(v)    setPreferredSize(w, h)    setProperties([path], props)    setRightPadding(right)    setSize(w, h)    setTopPadding(top)    setVisible(b)    toBack( )    toFront( )    toPreferredHeight( )    toPreferredSize( )    toPreferredWidth( )    toView(target)    validate( )    validateMetric( )    vrp( )   

public <zebkit.ui.Panel> getCheck ( )

Get check state component

Returns: <zebkit.ui.Panel>

a check state component

public <zebkit.ui.Panel> getContent ( )

Get content component

Returns: <zebkit.ui.Panel>

a content component

protected <zebkit.ui.Panel> getSub ( )

Get menu item child component to render sub item arrow element

Returns: <zebkit.ui.Panel>

a sub item arrow component

public <Boolean> isChecked ( )

Get checked state of the item

Returns: <Boolean>

a checked state

public void itemSelected ( )

Callback method that is called every time the menu item has been selected.

public void setGroup (g, [v])

Set group

public chainable setIcon (img)

Set the menu item icon.

  • img <String | Image>

    a path to an image or image object

@Override zebkit.layout.Layoutable
public void setParent (p)

Override setParent method to catch the moment when the item is inserted to a menu


Inherited attributes:
public zebkit.draw.View bg    public zebkit.draw.View border    public Boolean canHaveFocus    public Object constraints    public Integer height    public Boolean isEnabled    public Boolean isValid    public Boolean isVisible    public Array kids    public zebkit.layout.Layout layout    public zebkit.layout.Layoutable parent    public Integer width    public Integer x    public Integer y   

public <Integer> gap

Gap between checked, content and sub menu arrow components