Zebra API Doc

zebra.ui.MenuItem Class

Extends zebra.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.

Constructor

zebra.ui.MenuItem

(
  • caption
)

Parameters:

  • caption String | zebra.ui.Panel

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

    • "Menu Item [@menu_item_id]" - triggers creation of menu item component with "Menu Item" caption and "menu_item_id" id property value
    • "[x] Menu Item" - triggers creation of checked menu item component with checked on state
    • "@('mypicture.gif') Menu Item" - triggers creation of menu item component with "Menu Item" caption and loaded mypicture.gif icon

      // create menu item with icon and "Item 1" title var mi = new zebra.ui.MenuItem("@('mypicture.gif') Item 1");

Methods

getCheck

() zebra.ui.Panel protected

Get check state component


Return: zebra.ui.Panel

a check state component

getCheckState

() Boolean

Get menu item checked state


Return: Boolean

a menu item checked state

getContent

() zebra.ui.Panel protected

Get content component


Return: zebra.ui.Panel

a content component

getSub

() zebra.ui.Panel protected

Get menu item child component to render sub item arrow element


Return: zebra.ui.Panel

a sub item arrow component

hideSub

()

Hide sub menu arrow component

itemSelected

()

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

setCaption

(
  • caption
)

Set the menu item caption.

Parameters:

  • caption String

    a caption

setCheckManager

(
  • man
)

Set the menu item checked state manager.

Parameters:

setCheckState

(
  • b
)

Set the menu item checked state

Parameters:

  • b Boolean

    a checked state

setIcon

(
  • img
)

Set the menu item icon.

Parameters:

  • img String | Image

    a path to an image or image object

setParent

(
  • p
)

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

Parameters:

switched

(
  • b
)
protected

Callback method that is called every time a checked state of the menu item has been updated

Parameters:

  • b Boolean

    a new checked state

Attributes

gap

Integer readonly

Gap between checked, content and sub menu arrow components

Default: 8

manager

zebra.ui.SwitchManager | zebra.ui.Group readonly

Switch manager that is set to make the item checkable