XUL Programmer's Reference Manual
|
|||||||||||||||||||||||||||||
<menuitem />
<menuitem> is the widget that represents the actual item in the menu. menuitems typically appear as children of a menupopup whose own parent is a <menu>. The basic structure of a XUL menu is as follows:
|
|||||||||||||||||||||||||||||
value | |||||||||||||||||||||||||||||
Description
The value attribute specifies the name displayed for the menuitem.Syntax <menuitem value="string" />Example <menuitem value="New" />Notes |
|||||||||||||||||||||||||||||
checked | |||||||||||||||||||||||||||||
Description
When checked is set to "true", the menu itself appears with a check mark next to it in the menubar.Syntax checked="[true | false]"Example <menuitem value="AutoSave" checked="true" />Notes Menuitems can be checked in this way, or they can be created as part of a radio or checkbox menu type (see the type attribute below), in which case the checkmarks appear without having to set this attribute. You can check for the state of this attribute by using something like the following in javascript, where "autosave" is the id of the menuitem: |
|||||||||||||||||||||||||||||
oncommand | |||||||||||||||||||||||||||||
Description
oncommand is an optional attribute for creating event handlers for key bindings and menu commands.Syntax <menuitem id="string" value="string" oncommand="event handler code" />Example <menuitem id="saveKey" value="Save All" oncommand="SaveAll()" />Notes one..
|
|||||||||||||||||||||||||||||
type | |||||||||||||||||||||||||||||
Description
The typeattribute specifies the kind of menu that contains the given menuitem(s).Syntax <menuitem type="[ radio | checkbox ]" />Example <menuitem value="Auto Save" type="radio" name="save_type" />Notes In addition to the default menu type, which has no check marks or other indicators, you can also use the type attribute to specify menuitems of type radio and checkbox. Type, in this case, is a function of the menuitems and not the menu itself. |
|||||||||||||||||||||||||||||
name | |||||||||||||||||||||||||||||
Description
name is used to associated radio menuitems with one another.Syntax name="string"Example <menuitem value="Auto Save" type="radio" name="save_type" />Notes It is not necessary to use names with checkbox type menus, because the menuitems function independently of one another. Note also that you can name only a portion of the menuitems in a particular menu to make a set; not all menuittems within a particular menu need to be part of the same set. |
|||||||||||||||||||||||||||||
data | |||||||||||||||||||||||||||||
Description
data is an optional attribute used to specify additional text associated with the menuitem.Syntax <menuitem data="string">Example <menuitem id="hidden" value="one thing" data="another thing"Notes The data attribute provides a convenient way to hold extra text for a menuitem, text that can be hidden from the user but accessed programmatically when necessary. For example, to access the data of the menuitem in the example above, simply get the menuitem and ask for the value of its data attribute: |