Visit Mozilla.org

XUL:richlistbox

From MDC

(Redirected from XUL:Richlistbox)

« XUL Reference home    [ Examples | Attributes | Properties | Methods | Related ]

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, rows, seltype, suppressonselect, tabindex, value
Properties
accessibleType, currentIndex, currentItem, disabled, disableKeyNavigation, itemCount, 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

[edit] 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.

[edit] 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, querytype, ref, removeelement, sortDirection, sortResource, sortResource2, statustext, style, template, tooltip, tooltiptext, top, uri, wait-cursor, width

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.

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: element id
Connects the element 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 element.

rows
Type: integer
The number of rows to display in the element. If the element contains more than this number of rows, a scrollbar will appear which the user can use to scroll to the other rows. To get the actual number of rows in the element, use the getRowCount method.

seltype New in Firefox 3
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.)
  • multiple: Multiple rows may be selected at once. (Default in tree.)


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.

[edit] Properties

Inherited from XUL element
align, allowEvents, boxObject, builder, className, collapsed, contextMenu, controllers, currentItem, database, datasources, dir, flex, height, hidden, id, left, listBoxObject, maxHeight, maxWidth, menu, minHeight, minWidth, observes, ordinal, orient, pack, persist, ref, resource, statusText, style, tooltip, tooltipText, top, value, width

Inherited from DOM element
attributes, childNodes, cloneNode, firstChild, lastChild, localName, namespaceURI, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentNode, prefix, previousSibling, tagName

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. 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 New in Firefox 3
Type: integer
Read only property holding the number of child items.

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.

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 element 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 New in Firefox 3
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.

[edit] Methods

Inherited from XUL element
blur, click, doCommand, focus, getElementsByAttribute

Inherited from DOM element
addEventListener, appendChild, dispatchEvent, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getElementsByTagName, getElementsByTagNameNS, hasAttribute, hasAttributeNS, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, removeEventListener, replaceChild, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS

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.

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

[edit] Related

Interfaces
nsIAccessibleProvider, nsIDOMXULMultiSelectControlElement