richlistbox

This element is used to create a list of listitems (richlistitems), similar to a listbox, but is designed to be used when the items do not contain simple text content.

Note: In versions of Firefox prior to Firefox 3, rich list boxes support only single selection. Firefox 3 introduced multiple selection to rich list boxes.

Attributes
disabled, disableKeyNavigation, preference, seltype, suppressonselect, tabindex, value
Properties
accessibleType, currentIndex, currentItem, disabled, disableKeyNavigation, itemCount, scrollBoxObject, selectedCount, selectedIndex, selectedItem, selectedItems, selType, suppressOnSelect, tabIndex, value
Methods
addItemToSelection, appendItem, clearSelection, ensureElementIsVisible, ensureIndexIsVisible, getIndexOfFirstVisibleRow, getIndexOfItem, getItemAtIndex, getNumberofVisibleRows, getRowCount, getSelectedItem, insertItemAt, invertSelection, moveByOffset, removeItemAt, removeItemFromSelection, scrollToIndex, selectAll, selectItem, selectItemRange, timedSelect, toggleItemSelection

Examples

<richlistbox>
  <richlistitem>
    <description>A XUL Description!</description>
  </richlistitem>
  <richlistitem>
    <button label="A XUL Button"/>
  </richlistitem>
</richlistbox>

The richlistbox element contains multiple richlistitem elements, which can contain any content. You can click on any richlistitem element and use the keyboard to move the selection around.

Attributes

disabled
Type: boolean
Indicates whether the element is disabled or not. If this element is set to true the element is disabled. Disabled elements are usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused, and the command event will not fire.
Visible controls have a disabled property which, except for menus and menuitems, is normally preferred to use of the attribute, as it may need to update additional state.
disableKeyNavigation
Type: boolean
If this attribute is not used, the user can navigate to specific items within the element by pressing keys corresponding to letters in the item's label. This is done incrementally, so typing more letters with select more specific items. This feature may be disabled by setting this attribute to true.
preference
Type: id
Connects the element to a corresponding preference. This attribute only has any effect when used inside a prefwindow. More information is available in the Preferences System article.
 
seltype
Type: one of the values below
Used to indicate whether multiple selection is allowed.
single
Only one row may be selected at a time. (Default in listbox and richlistbox.)
multiple
Multiple rows may be selected at once. (Default in tree.)

For trees, you can also use the following values:

cell
Individual cells can be selected
text
Rows are selected; however, the selection highlight appears only over the text of the primary column.

For richlistbox, this is new in Firefox 3.5.

suppressonselect
Type: boolean
If this attribute is not specified, a select event is fired whenever an item is selected, either by the user or by calling one of the select methods. If set to true, the select event is never fired.
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 sequence.
value
Type: string
The string attribute allows you to associate a data value with an element. It is not used for any specific purpose, but you can access it with a script for your own use. Be aware, however, that some elements, such as textbox will display the value visually, so in order to merely associate data with an element, you could 1) Use another attribute like "value2" or "data-myAtt" (as in the HTML5 draft), as XUL does not require validation (less future-proof); 2) Use setAttributeNS() to put custom attributes in a non-XUL namespace (serializable and future-proof); 3) Use setUserData() (future-proof and clean, but not easily serializable). For user editable menulist elements, the contents, as visible to the user, are read and set using the Menulist.value syntax. For those elements, setAttribute("value", myValue) and getAttribute("value") do not access or affect the contents displayed to the user.

 

Properties

accessibleType
Type: integer
A value indicating the type of accessibility object for the element.
currentIndex
Type: integer
Set to the index of the currently focused item in the list. If no item is focused, the value will be -1. (or, on some platforms, typeof(listboxcurrentIndex) will be undefined) In a single selection list, the current index will always be the same as the selected index. In a multiple selection list, the currently focused row may be modified by the user without changing the selection by pressing the Control key and pressing the cursor keys to navigate.
currentItem
Type: listitem element
Returns the last selected item in the list box, which is only useful in a multiple selection list box.
disabled
Type: boolean
Gets and sets the value of the disabled attribute.
disableKeyNavigation
Type: boolean
Gets or sets the value of the disableKeyNavigation attribute.
itemCount
Type: integer
Read only property holding the number of child items.
scrollBoxObject
Type: nsIScrollBoxObject
The scroll box object implements the nsIScrollBoxObject interface, which may be used to retrieve and adjust the scroll position of the list box.
selectedCount
Type: integer
Returns the number of items that are currently selected.
selectedIndex
Type: integer
Returns the index of the currently selected item. You may select an item by assigning its index to this property. By assigning -1 to this property, all items will be deselected. Returns -1 if no items are selected
selectedItem
Type: element
Holds the currently selected item. If no item is currently selected, this value will be null. You can select an item by setting this value. A select event will be sent to the controlling container (i.e. the listbox, richlistbox, radiogroup, etc., not the list item that was selected) when it is changed either via this property, the selectedIndex property, or changed by the user.
selectedItems
Type: array of listitems
Returns an array of the selected items in the list.
selType
Type: string
Gets and sets the value of the seltype attribute.

 

suppressOnSelect
Type: boolean
Gets and sets the value of the suppressonselect attribute.
tabIndex
Type: integer
Gets and sets the value of the tabindex attribute.
value
Type: string
Gets and sets the value of the value attribute. For textbox and user editable menulist elements, the contents, as visible to the user, are read and set using the Textbox.value and Menulist.value syntax.

 

Methods

Inherited Methods
addEventListener(), appendChild(), blur, click, cloneNode(), compareDocumentPosition, dispatchEvent(), doCommand, focus, getAttribute(), getAttributeNode(), getAttributeNodeNS(), getAttributeNS(), getBoundingClientRect(), getClientRects(), getElementsByAttribute, getElementsByAttributeNS, getElementsByClassName(), getElementsByTagName(), getElementsByTagNameNS(), getFeature(), getUserData, hasAttribute(), hasAttributeNS(), hasAttributes(), hasChildNodes(), insertBefore(), isDefaultNamespace(), isEqualNode, isSameNode, isSupported(), lookupNamespaceURI, lookupPrefix, normalize(), querySelector(), querySelectorAll(), removeAttribute(), removeAttributeNode(), removeAttributeNS(), removeChild(), removeEventListener(), replaceChild(), setAttribute(), setAttributeNode(), setAttributeNodeNS(), setAttributeNS(), setUserData

addItemToSelection( item )
Return type: no return value
Selects the given item, without deselecting any other items that are already selected.
appendItem( label, value )
Return type: element
Creates a new item and adds it to the end of the existing list of items. You may optionally set a value. The function returns the newly created element.
clearSelection()
Return type: no return value
Deselects all of the items.  A select event is sent before the items are deselected.
ensureElementIsVisible( element )
Return type: no return value
If the specified element is not currently visible to the user, the displayed items are scrolled so that it is. If the item is already visible, no scrolling occurs.
ensureIndexIsVisible( index )
Return type: no return value
If the item at the specified index is not currently visible to the user the displayed items are scrolled so that it is. If the item is already visible, no scrolling occurs.
getIndexOfFirstVisibleRow()
Return type: integer
Returns the index of the first displayed row. Note that this is not the same as the first row -- if the displayed items have been scrolled down, this function will retrieve the index of the first row that the user can see.
getIndexOfItem( item )
Return type: integer
Returns the zero-based position of the specified item. Items are numbered starting at the first item displayed in the list.
getItemAtIndex( index )
Return type: element
Returns the element that is at the specified index.
getNumberOfVisibleRows()
Return type: integer
Returns the number of rows that are currently visible to the user.
getRowCount()
Return type: integer
Returns the total number of rows in the element, regardless of how many rows are displayed.
getSelectedItem( index )
Return type: element
When multiple items are selected, you can retrieve each selected item using this method. The argument <var>index</var> specifies the index in the list of the selected items, not the row number of the item. The item index is zero-based, thus this example will return the first selected item: getSelectedItem(0).
insertItemAt( index, label, value )
Return type: element
This method creates a new item and inserts it at the specified position. You may optionally set a value. The new item element is returned.
invertSelection()
Return type: no return value
Reverses the selected state of all items. Selected items become deselected, and deselected items become selected.
moveByOffset( offset , isSelecting, isSelectingRange)
Return type: no return value
If offset is positive, adjusts the focused item forward by that many items. If offset is negative, adjusts the focused item backward by that many items. If isSelecting is true, then the selection is also adjusted. If isSelectingRange is also true, then the new item is selected in addition to any currently selected items. If isSelectingRange is false, any existing selection is cleared. Items that are hidden are skipped.
removeItemAt( index )
Return type: element
Removes the child item in the element at the specified index. The method returns the removed item.
removeItemFromSelection( item )
Return type: no return value
Deselects the specified item without deselecting other items.
scrollToIndex( index )
Return type: no return value
Scrolls the element to the specified index. This is different than ensureIndexIsVisible because the view is always scrolled.
selectAll()
Return type: no return value
Selects all of the items. A select event is sent after the selection is made.
selectItem( item )
Return type: no return value
Deselects all of the currently selected items and selects the given item. A select event is sent after the selection is made.
selectItemRange( startItem, endItem )
Return type: no return value
Selects the items between the two items given as arguments, including the start and end items. All other items are deselected. This method does nothing for single-selection list boxes. A select event is sent after the selection is made.
timedSelect( item, timeout )
Return type: no return value
Selects the item specified by the argument item after the number of milliseconds given by the timeout argument. All other items are deselected.
toggleItemSelection( item )
Return type: no return value
If the specified item is selected, it is deselected. If it is not selected, it is selected. Other items in the list box that are selected are not affected, and retain their selected state.

Interfaces
nsIAccessibleProvider, nsIDOMXULMultiSelectControlElement

Document Tags and Contributors

 Last updated by: Sheppy,