menuItem element (used with Interface module)
Description:
This element is used to create menus. You create menuItems, then add them to a menu object, which is in turn added to another menu or an interface object.
To use:
The code for this element is included in the interface module, linked as follows:
<script language="Javascript" src="gamelib_interface.js"></script>
You then instantiate a menuItem object by adding the following to your script:
myMenuItem=new In_MenuItem('Open','alert(\'open\')',true);
The parameters to pass as this object is constructed are firstly the text to display for this menu item, then the action to be performed when it's clicked, and finally true (the third parameter is always true in this version of gamelib.) After you've done this, you must add the menuItem to a menu object, and that menu object must be added to an Interface before it can be used.
List of methods for menuItem
Descriptions of methods for menuItem
Method | Parameters | Description |
---|---|---|
disable | (none) | Disables this menuItem. The item is still displayed in the menu, but it uses the disabled background colour set in its parent menu object, and will not respond to the mouse. |
enable | (none) | Re-enables the menuItem. This is the default state for all menuItems. |
setAction | String | Sets the action to be performed when the menuItem is clicked. This could be any legal javascript statement, but would normally be used to call a function in the main script. |