Zebra API Doc

zebra.ui.Menu Class

Menu UI component class. The class implements popup menu UI component.

var m = new Menu({
   "Menu Item 1" : [
       "[x] SubMenu Checked Item 1",
       "[ ] SubMenu Unchecked Item 2",
       "-",   // line
       "[ ] SubMenu Unchecked Item 3"
   ],
   "Menu Item 2" : null,
   "Menu Item 3" : null
});

Constructor

zebra.ui.Menu

(
  • [list]
)

Parameters:

  • [list] Object optional

    use special notation to define a menu

       {
           'Menu Item 1': null,   // menu item 1 without a sub menu
           'Menu Item 2': null,   // menu item 2 without a sub menu
           '-':null,              // decorative line element 
           'Menu Item 3': {       // menu item 3 with a sub menu defined
               "[x] Checkable menu item":null, // checkable menu item
               "Sub item 1":null
           }
       }

Methods

$canceled

(
  • m
)
protected

Called when the menu or a sub-menu has been canceled (key ESCAPE has been pressed).

Parameters:

$childMenu

() zebra.ui.Menu protected

Get a sub menu that is shown at the given moment.


Return: zebra.ui.Menu

a child sub menu. null if no child sub-menu has been shown

$hideMenu

(
  • triggeredBy
)
protected

Hide the menu and all visible sub-menus

Parameters:

  • triggeredBy zebra.ui.Menu

    a menu that has triggered the hiding of menu hierarchy

$showSubMenu

(
  • sub
)
protected

Show the given sub menu

Parameters:

$topMenu

() zebra.ui.Menu protected

Get the top menu in the given shown popup menu hierarchy


Return: zebra.ui.Menu

a top menu

addDecorative

(
  • c
)

Add the specified component as a decorative item of the menu

Parameters:

childCompEvent

(
  • id
  • src
  • p1
  • p2
)

Define component events handler.

Parameters:

  • id Integer

    a component event id

  • src zebra.ui,Panel

    a component that triggers the event

  • p1 Object

    a first event parameter.

  • p2 Object

    a second event parameter

getMenuAt

(
  • index
)
zebra.ui.Menu

Get a sub menu for the given menu item

Parameters:

  • index Integer

    a menu item index


Return: zebra.ui.Menu

a sub menu or null if no sub menu is defined for the given menu item

getMenuItem

(
  • i
)
zebra.ui.Panel

Get a menu item by the given index

Parameters:

  • i Integer

    a menu item index


Return: zebra.ui.Panel

a menu item component

hasSelectableItems

() Boolean

Test if the menu has a selectable item


Return: Boolean

true if the menu has at least one selectable item

indexMenuOf

(
  • menu
)
Integer

Get the specified sub-menu index

Parameters:


Return: Integer

a sub menu index. -1 if the menu is not a sub menu of the given menu

isDecorative

(
  • i
)
Boolean

Test if the given menu item is a decorative (not selectable) menu item. Menu item is considered as decorative if it has been added with addDecorative(...) method or has "$isDecorative" property set to "true"

Parameters:

  • i Integer

    a menu item index


Return: Boolean

true if the given menu item is decorative

keyPressed

(
  • e
)

Override key pressed events handler to handle key events according to context menu component requirements

Parameters:

mouseExited

(
  • e
)

Define mouse exited events handler

Parameters:

setMenuAt

(
  • i
  • m
)

Set the given menu as a sub-menu for the specified menu item

Parameters:

  • i Integer

    an index of a menu item for that a sub menu has to be attached

  • m zebra.ui.Menu

    a sub menu to be attached

Attributes

decoratives

Object { {zebra.ui.Panel}:true } private readonly

Dictionary to keep decorative components