References > " . "Element Reference"; $pagetitle="Menulist"; $customsidebar = "elemref-sidebar.php"; include "header.php"; ?>

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 src
tabindex value

Properties and Methods:

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

Attributes:

Inherited from XUL Element:

align
allowevents
allownegativeassertions
class
coalesceduplicatearcs
collapsed
container
containment
context
contextmenu
datasources
debug
dir
empty
equalsize
flags
flex
height
hidden
id
insertafter
insertbefore
left
maxheight
maxwidth
menu
minheight
minwidth
observes
ordinal
orient
pack
persist
popup
position
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 right to left (rtl), 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.

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.


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 )

Return Type: menuitem element

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

crop

Type: string

Gets and sets the value of the crop attribute.

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 )

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

value

Type: string

Gets and sets the value of the value attribute.