PackageTop Level
Classpublic class MenuItem

Menu items are used in conjunction with the Menu class to build menus.

See also

Menu


Public Methods
 MethodDefined by
  
MenuItem(text:String)
Constructor.
MenuItem
  
getId():String
Gets the id of the menu item.
MenuItem
  
getOnSelected():String
Gets the "onSelected" event handler.
MenuItem
  
getTag():String
Gets the tag property of the menu item.
MenuItem
  
getText():String
Gets the text (label) property of the menu item.
MenuItem
  
setId(id:String):void
Sets the id of the menu item.
MenuItem
  
setOnSelected(functionName:String):void
Sets the "onSelected" event handler.
MenuItem
  
setTag(tag:String):void
Sets the tag property of the menu item.
MenuItem
  
setText(text:String):void
Sets the text (label) property of the menu item.
MenuItem
Constructor detail
MenuItem()constructor
public function MenuItem(text:String)

Constructor.

Parameters
text:String — The text (label) of the menu item.
Method detail
getId()method
public function getId():String

Gets the id of the menu item.

Returns
String — Menu item ID.
getOnSelected()method 
public function getOnSelected():String

Gets the "onSelected" event handler.

Returns
String — Name of the menu item event handler.
getTag()method 
public function getTag():String

Gets the tag property of the menu item.

Returns
String — Menu item tag.
getText()method 
public function getText():String

Gets the text (label) property of the menu item.

Returns
String — Menu item text.
setId()method 
public function setId(id:String):void

Sets the id of the menu item. The menu item ID is user-defined and can be any string.

Parameters
id:String — Menu item ID.
setOnSelected()method 
public function setOnSelected(functionName:String):void

Sets the "onSelected" event handler. The associated function will be called when the user selects this particular menu item.

Parameters
functionName:String — Name of the menu item event handler.

Example
The examples below creates a menu, associate a menu item with it, and displays a message when the item is clicked.
  
 -- Create a new menu  
 menu = Menu:new("My menu")  
  
 -- Create a new menu item  
 menuItem = MenuItem:new("my menu item")  
  
 -- Set the menu item event handler  
 menuItem:setOnSelected("menuItem_selected")  
  
 -- This function will be called when the menu item is clicked:  
 function menuItem_selected(event)  
     dialogs:showMessage("'"..event.menuItem:getText().."' was clicked!")  
 end  
 

setTag()method 
public function setTag(tag:String):void

Sets the tag property of the menu item. The menu item tag is user-defined and can be any string. It can be used to associate some additional data, such as the ID of an object, to the menu item.

Parameters
tag:String — Menu item tag.
setText()method 
public function setText(text:String):void

Sets the text (label) property of the menu item.

Parameters
text:String — Menu item text.