Menulist

An element that can be used for drop-down choice lists. The user may select one of the elements displayed in the menulist. The currently selected choice is displayed on the menulist element. To create the drop-down, put a menupopup inside the menulist containing the choices as menuitem elements.

More information about menulist

The menulist element implements the following interfaces:

nsIAccessibleProvider   nsIDOMXULMenuListElement  

Attributes:

accesskey crop disableautoselect disabled editable
focused image label open preference
readonly sizetopopup src tabindex value

Properties and Methods:

accessible appendItem crop description disableautoselect
disabled inputField insertItemAt label menuBoxObject
menupopup open removeAllItems removeItemAt select
selectedIndex selectedItem src tabIndex value

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

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 menulist. 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 menulist 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.

crop

Type: one of the values below

If the label of the menulist 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.

disableautoselect

Type: boolean

If this attribute is true or omitted, the selected item on the menu will update to match what the user entered in the textbox. If the text does not match any of the items in the list, the menu selection is cleared. If this attribute is false, the selection is never updated to match the text box. This attribute applies only to editable menulists.

disabled

Type: boolean

Indicates whether the menulist is disabled or not. If this attribute is set to true, the menulist is disabled. This is usually drawn with the text in grey. If the menulist 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 menulist, leave the attribute out entirely as opposed to setting the value to false.

editable

Type: boolean

Indicates that the value of the menulist can be modified by typing directly into the value field. This is rendered as a textbox with a drop-down arrow beside it. The user may enter text into the textbox or select one of the choices by clicking from the drop-down.

focused

Type: boolean

This attribute is set to true if the menulist element is focused.

image

Type: image URL

The URL of the image to appear on the menulist. If this is attribute is left out, no image appears. The position of the image is determined by the dir and orient attributes.

label

Type: string

The label that will appear on the menulist. If this is left out, no text appears.

open

Type: boolean

If true, the menu popup is showing. You can change this value to show or hide the popup.

preference    Mozilla 1.8

Type: element id

Connects the menulist to a corresponding preference. This attribute only has any effect when used inside a prefwindow. The value of the preference will be updated to match the value property of the menulist.

readonly

Type: boolean

If set to true, then the user cannot type into the field of an editable menulist. However, the value may still be modified by a script.

sizetopopup

Type: string

Indicates how the menu width and the popup width are determined. If the sizetopopup attribute is left out or set to none, the menu will be its preferred width and the popup may extend outside of this width, unaffected by the maximum width of the menu itself.

src

Type: image URL

The URL of the image to appear on the menulist. If this attribute is left out, no image appears.

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.

value

Type: string

The value of the value property of the currently selected item in the menulist. You can select an item with a particular value by setting this property.


Properties and Methods:

Inherited from XUL Element:

align
allowEvents
blur
boxObject
boxObject.element
boxObject.getLookAndFeelMetric
boxObject.height
boxObject.screenX
boxObject.screenY
boxObject.width
boxObject.x
boxObject.y
builder
className
click
collapsed
contextMenu
controllers
database
datasources
dir
doCommand
flex
focus
getElementsByAttribute
height
hidden
id
left
maxHeight
maxWidth
menu
minHeight
minWidth
observes
ordinal
orient
pack
persist
ref
resource
statusText
style
tooltip
tooltipText
top
width

Inherited from Element:

addEventListener
appendChild
attributes
childNodes
cloneNode
dispatchEvent
firstChild
getAttribute
getAttributeNS
getAttributeNode
getAttributeNodeNS
getElementsByTagName
getElementsByTagNameNS
hasAttribute
hasAttributeNS
hasAttributes
hasChildNodes
insertBefore
isSupported
lastChild
localName
namespaceURI
nextSibling
nodeName
nodeType
nodeValue
normalize
ownerDocument
parentNode
prefix
previousSibling
removeAttribute
removeAttributeNS
removeAttributeNode
removeChild
removeEventListener
replaceChild
setAttribute
setAttributeNS
setAttributeNode
setAttributeNodeNS
tagName

accessible

Type: nsIAccessible

Returns the accessibility object for the menulist.

appendItem ( label , value , description )

Return Type: menuitem element

Creates a new menuitem element and adds it to the end of the menulist. You may optionally set a value and description. The function returns the new item.

crop

Type: string

Gets and sets the value of the crop attribute.

description    Mozilla 1.8

Type: string

Set to the description of the currently selected menuitem.

disableautoselect

Type: boolean

Gets and sets the value of the disableautoselect attribute.

disabled

Type: boolean

Gets and sets the value of the disabled attribute.

inputField

Type: textbox element

A reference to the textbox element used for editable menu lists. This property is read only and applies to editable menulists only.

insertItemAt ( index , label , value , description )

Return Type: menuitem element

Creates a new menuitem element and inserts it at a specific position in the menu. You may optionally set a value and description. The function returns the new item.

label

Type: string

Gets and sets the value of the label attribute.

menuBoxObject    Moz1.3

Type: nsIMenuBoxObject

A reference to the nsIMenuBoxObject which implements the menu.

menupopup    Moz1.3

Type: menupopup element

A reference to the menupopup used by the menulist. This property is read-only.

open

Type: boolean

Gets and sets the value of the open attribute.

removeAllItems ( )     Moz1.3

Return Type: no return value

Removes all of the items in the menu.

removeItemAt ( index )

Return Type: menuitem element

Removes the child item in the menu at the given index. The function returns the removed item.

select ( )     Moz1.3

Return Type: no return value

Select all the text in the menulist's textbox. This property applies to editable menulists only.

selectedIndex

Type: integer

Holds the index of the currently selected item in the menu. If no item is currently selected, this will be set to -1. You can select an item by setting this value.

selectedItem

Type: menuitem element

Holds the element of the menu that is currently selected. If no element is currently selected, this will be null. Use selectedIndex to retrieve the position of the selected item in the menu.

src

Type: image URL

Gets and sets the value of the src attribute.

tabIndex    Mozilla 1.8

Type: integer

Get and sets the value of the tabindex attribute.

value

Type: string

Gets and sets the value of the value attribute.


Copyright (C) 1999 - 2004 XulPlanet.com