Menuitem
A single choice in a menupopup element. It acts much like a button but it is rendered on a menu.
More information about menuitem
Attributes:
acceltext | accessible | accesskey | allowevents | autocheck |
checked | command | crop | description | disabled |
image | key | label | name | selected |
tabindex | type | validate | value |
Style Classes:
menuitem-iconic | menuitem-non-iconic |
Attributes:
Inherited from XUL Element:
align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
mousethrough
observes
ordinal
orient
pack
persist
popup
position
preference-editable
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width
acceltext
Type: string
Text that appears beside beside the menu label to indicate the shortcut key (accelerator key) to use to invoke the command. If this value is set, it overrides an assigned key set in the key attribute. This attribute does not apply to menus directly on the menubar.
accessible
Type: nsIAccessible
Returns the accessibility object for the menuitem.
accesskey
Type: character
This should be set to a letter that is used as a shortcut key. This letter should be one of the characters that appears in the label text for the menuitem. This letter will typically be drawn underlined, although this behavior will be platform and theme specific. When the user presses ALT (or a similar key that varies on each platform) and the access key, the menuitem will be activated from anywhere in the window. Although the value is case insensitive, a letter with the case matching the accesskey attribute will used if both cases exist in the label.
allowevents
Type: boolean
If true, events are passed to children of the menuitem. Otherwise, events are passed to the menuitem only.
autocheck
If this attribute is true, or left out, the menuitem check mark will update each time the menu item is selected. If this attribute is false, the check mark must be adjusted manually.
checked
Type: boolean
Indicates whether the menuitem is checked or not.
command
Type: element id
Set to the id of a command element that is being observed by the menuitem. If the command element's disabled attribute is set to true, the menuitem will become disabled. If the command disabled attribue is removed, the menuitem will be enabled. Similarly, the command's label attribute can be used to set the menuitem's label.
crop
Type: one of the values below
If the label of the menuitem is too small to fit in its given space, the text will be cropped on the side specified by the crop attribute. An ellipsis will be used in place of the cropped text. If the box direction is reversed, the cropping is reversed.
- start: The text will be cropped on its left side.
- end: The text will be cropped on its right side.
- left: (Deprecated) The text will be cropped on its left side.
- right: (Deprecated) The text will be cropped on its right side.
- center: The text will be cropped on both sides.
- none: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.
description Mozilla 1.8
Type: string
An optional description to appear alongside the label. This is typically used for a menuitem in a menulist.
disabled
Type: boolean
Indicates whether the menuitem is disabled or not. If this attribute is set to true, the menuitem is disabled. This is usually drawn with the text in grey. If the menuitem is disabled, it does not respond to user actions. The element cannot be focused and the command event will not fire. The element will still respond to mouse events. To enable the menuitem, leave the attribute out entirely as opposed to setting the value to false.
image
Type: image URL
The URL of the image to appear on the menuitem. If this is attribute is left out, no image appears. The position of the image is determined by the dir and orient attributes. You must use the class 'menuitem-iconic' to have an image appear.
key
Type: key element id
The id of a key element that is used as the menu command's shortcut key. If used, text will be displayed beside the menu label to indicate which keys can be pressed to invoke the command.
label
Type: string
The label that will appear on the menuitem. If this is left out, no text appears.
name
Type: string name
Radio menuitems with the same name as put into a group. Only one menuitem from each radio group can be checked at a time.
selected
Type: boolean
Indicates that the menuitem is selected in a menulist. This property is read only. To change the selection, set either the selectedIndex or selectedItem property of the containing menulist.
tabindex
Type: integer
The tab order of the element. The tab order is the order in which the focus is moved when the user presses the Tab key. Elements with a higher tabindex are later in the tab order sequence.
type
Type: one of the values below
Can be used to create checkable menuitems or for radio button menuitems.
- checkbox: The menuitem is checked. The checked attribute determines whether the menuitem is checked or not.
- radio: The menuitem becomes part of a radio group. Other menuitems that have the same value for their name attributes are part of the same radio group. Only one menuitem in the same radio group can be checked at once.
validate
Type: one of the values below
This attribute indicates whether to load the image from the cache or not. This would be useful if the images are stored remotely or you plan on swapping the image frequently. The following values are accepted, or leave out the attribute entirely for default handling:
- always: The image is always checked to see whether it should be reloaded.
- never: The image will be loaded from the cache if possible.
value
Type: string
You can associate a data value with each menu and menuitem. It is not used for any specific purpose but you can access it with a script for your own use.
Style Classes:
The following classes may be used to style the element. These classes should be used instead of changing the style of the element directly since they will fit more naturally with the user's selected theme.
menuitem-iconic
Use this class to have an image appear on the menuitem. Specify the image using the image attribute.
menuitem-non-iconic
Normally, menuitems have a margin to the left for an image or checkmark. This class may be used to remove this margin so that the menuitem appears on the left edge of the menupopup.
Properties and Methods:
label
Type: string
Gets and sets the value of the label attribute.
value
Type: string
Gets and sets the value of the value attribute.
Inherited from XUL Element:
Inherited from Element: