Name

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

Synopsis

LZX: menu
JavaScript: menu
Type: Class
Access: public
Topic: Components.Laszlo Components
Declared in: lps/components/lz/menu.lzx

Description

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 menuitems and menuseparators. 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 46. 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.write(vThis.parent.owner.text + " - "+ vThis.text);
               </method>
               </canvas>
             

Example 47. 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>
             

Superclass Chain

node (LzNode) » view (LzView) » basecomponent » menu

Known Subclasses

Details

Properties (3)

attach
<attribute name="attach" type="string" value="bottom" />
public var attach : String;
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
<attribute name="opened" value="false" />
public var opened;
a boolean indicating whether or not the menu is in opened
text
<attribute name="text" type="html" value="menutitle" />
public var text : html;
the test that appears in the menu button if the menu is a subview of a menubar

Methods (5)

close()
<method name="close" />
public function 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.
createChildren()
<method name="createChildren" args="childrenarray" />
public function createChildren(childrenarray);
getTopMenu()
<method name="getTopMenu" />
public function getTopMenu();
finds the top most menu in the heirarchy associated with this menu
open()
<method name="open" args="openit" />
public function 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.
setOpen()
<method name="setOpen" args="isopened" />
public function 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()

LZX Synopsis

<class name="menu" extends=" basecomponent ">
  <attribute name=" attach " type="string" value="bottom" />
  <attribute name=" opened " value="false" />
  <attribute name=" text " type="html" value="menutitle" />
  <method name=" close " />
  <method name=" createChildren " args="childrenarray" />
  <method name=" getTopMenu " />
  <method name=" open " args="openit" />
  <method name=" setOpen " args="isopened" />
</class>

JavaScript Synopsis

public menu extends  basecomponent  {
  public var attach  : String;
  public var opened ;
  public var text  : html;
  prototype public function close ();
  prototype public function createChildren (childrenarray);
  prototype public function getTopMenu ();
  prototype public function open (openit : boolean);
  prototype public function setOpen (isopened : boolean);
}