<menu>
A pull-down menu that can be used within a menubar, a menuitem or any other view.

JavaScript: lz.menu
extends <basecomponent> » <view> » <node> » lz.Eventable »

The <menu> tag creates a menu that floats above all other views when activated. If a menu is a subview of a <menubar>, then it will create a "menubutton" in the menubar with the its text attribute equal to that of the menu's. This "menubutton" inherits its properties from <button>.

typical use of a menu is shown below, with its children of <menuitem>s and <menuseparator>s. Note, however, that the parent of a menuitem is not the menu itself, but rather a <floatinglist> that is implicity part of the menu. To access the menu from a menuitem (or any other subview) use the reference "parent.owner".

Example 59. using the menubar

<canvas debug="true" height="230">
               <debug y="100"/>
               <menubar width="200">
               <menu text="Menu 1" width="100">
               <menuitem text="Item 1" onselect="canvas.whichOne(this);"/>
               <menuitem text="Item 2" onselect="canvas.whichOne(this);"/>
               <menuitem text="Item 3" onselect="canvas.whichOne(this);"/>
               <menuseparator/>
               <menuitem text="Item 4" onselect="canvas.whichOne(this);"/>
               </menu>
               <menu text="Menu 2" width="100">
               <menuitem text="More items..." onselect="canvas.whichOne(this);"/>
               </menu>
               </menubar>

               <method name="whichOne" args="vThis">
               Debug.debug("%w - %w", vThis.parent.owner.text, vThis.text);
               </method>
               </canvas>

Example 60. simple menu

<canvas debug="true" height="235">
               <debug y="105"/>
               <button text="openMenu below">
               <menu name="topmenu" attach="bottom">
               <menuitem text="item 1"/>
               <menuitem text="item 2">
               <menu name="submenu">
               <menuitem text="subitem 1"/>
               <menuitem text="subitem 2"/>
               </menu>
               </menuitem>
               </menu>

               <handler name="onmousedown">
               this.topmenu.setOpen(true);
               </handler>
               </button>
               </canvas>

Attributes

Name (CSS property) Type (tag) Type (js) Default Category
attach string String bottom read/write
  a string to indicate how the floating part of the menu attaches to the menubutton or menuitem. Possible values are: 'top', 'bottom', 'left', and 'right'
opened boolean boolean false read/write
  a boolean indicating whether or not the menu is in opened
text html lz.html menutitle read/write
  the test that appears in the menu button if the menu is a subview of a menubar

Methods

close()
menu.close();
The general method to close a menu starting with itself and then moving 'down' the hierarchy to close all the other menus in the hierarchy.

getTopMenu()
menu.getTopMenu();
Finds the top most menu in the heirarchy associated with this menu
Returns Type Description
  Object top most menu

open()
menu.open(openit : Boolean);
The general method to open/close a menu starting with itself and then moving 'up' the hierarchy to open/close the other menus in the hierarchy.
Parameter Name Type Description
openit Boolean true opens menu, false closes it

setOpen()
menu.setOpen(isopened : Boolean);
Only Hides and shows the floating list associated with the menu. It does not effect any other part of the menu's heirarchy. To open a menu within a heirarchy use open() instead of setOpen()
Parameter Name Type Description
isopened Boolean true opens menu, false closes it

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy