Listbox

This element is used to create a list of items. This is a simpler version of a tree. Nested rows are not supported, but a listbox may contain multiple columns. There are numerous methods which allow the items in the listbox to be retrieved and modified.

You may specify the number of rows to display in the list using the rows attribute. Additional rows can be viewed by using a scroll bar. All of the rows in the listbox are the same height, which is the height of the largest item in the list.

More information about listbox

Example:

    <listbox id="theList">
      <listitem label="Ruby"/>
      <listitem label="Emerald"/>
      <listitem label="Sapphire"/>
      <listitem label="Diamond"/>
    </listbox>

この要素は項目の一覧を作成するために利用される。これはツリーを単純化したものである。入れ子になった行はサポートされないが、リストボックスは複数の列を含むことができる。リストボックス内の項目を得たり、更新するために、何種類ものメソッドが用意されている。

rows 属性を使ってリストに表示する行数を指定することができる。残りの行はスクロールバーで見ることができる。リストボックスの行は全て同じ高さを持つ。この高さはリストで最大の項目の高さである。

listbox の追加情報

例 :

    <listbox id="theList">
      <listitem label="Ruby"/>
      <listitem label="Emerald"/>
      <listitem label="Sapphire"/>
      <listitem label="Diamond"/>
    </listbox>

属性:

disableKeyNavigation disabled rows seltype suppressonselect
tabindex value

プロパティとメソッド:

accessible addItemToSelection appendItem clearSelection currentItem
disableKeyNavigation disabled ensureElementIsVisible ensureIndexIsVisible getIndexOfFirstVisibleRow
getIndexOfItem getItemAtIndex getNextItem getNumberOfVisibleRows getPreviousItem
getRowCount getSelectedItem insertItemAt invertSelection listBoxObject
removeItemAt removeItemFromSelection scrollToIndex selType selectAll
selectItem selectItemRange selectedCount selectedIndex selectedItem
selectedItems timedSelect toggleItemSelection value

属性:

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
mousethrough
observes
ordinal
orient
pack
persist
popup
position
ref
removeelement
sortDirection
sortResource
sortResource2
statustext
style
template
tooltip
tooltiptext
top
uri
wait-cursor
width

disableKeyNavigation

Type: boolean

If this attribute is not used, the user can navigate to specific items in the list by pressing the first the first letter of the item's label. This is done incrementally, so pressing additional keys will select more specific items. This feature may be disabled for a listbox by setting this attribute to true.

型 : boolean

この属性が使われていないときには、項目のラベルの最初の文字を押すことにより、リストの特定の項目に移ることができる。これはインクリメンタルに行われるため、さらにキーを押すとより特定した項目を選択する。この属性を true に設定すると、リストボックスに対してこの機能を無効にすることができる。

disabled

Type: boolean

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

型 : boolean

リストボックスが無効か有効かを表す。この属性を true に設定すると、リストボックスは無効になる。通常、テキストが灰色で表示される。リストボックスが無効の場合には、ユーザアクションに応答しない。要素にフォーカスできず、またコマンドイベントは起きない。マウスイベントにはまだ応答する。リストボックスを有効にするには、値を false に設定したことに対応するものとして、この属性を取り除く。

rows

Type: integer

The number of rows to display in the list box. If the listbox contains more than this many 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 listbox, use the getRowCount method.

型 : integer

リストボックスに表示する行の数。listbox がこの行数より多く持っているときは、スクロールバーが現れてユーザが他の行にスクロールすることができる。listbox にある実際の行数を得るには、 getRowCount メソッドを使用する。

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.
  • multiple: Multiple rows may be selected at once.

型 : 以下の値の一つ

複数選択ができるかどうかを指定するのに使用される。

  • single: 一度に一行のみ選択可能。
  • multiple: 一度に複数行の選択が可能。
suppressonselect

Type: boolean

If this attribue 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.

型 : boolean

この属性を指定しないときには、ユーザが選択したり選択メソッドの一つが呼ばれたりして、項目が選択されたときにはいつも選択イベントが発生する。true に設定した場合、選択イベントは決して発生しない。

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.

型 : integer

要素のタブ順序。タブ順序は、ユーザがタブキーを押したときにフォーカスが移動する順番です。高い tabindex を持つ要素ほど、タブ順序の後のほうにくる。

value

Type: string

You can associate a data value with each listitem. It is not used for any specific purpose but you can access it with a script for your own use.

型 : string

各 listitem にデータ値を関連づけることができる。特定の目的のために使用されるわけではない。スクリプトで使用するためにアクセスすることができる。


プロパティとメソッド:

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

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

型 : nsIAccessible

リストボックスの accessibility オブジェクトを返す。

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: listitem element

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

戻り値の型 : listitem element

新しい listitem 要素を作成してリストボックスの末尾に追加する。オプションとして値を設定することができる。この関数は新しい項目を返す。

clearSelection ( )

Return Type: no return value

Deselects all of the items.

戻り値の型 : 戻り値なし

全項目を選択から解除する。

currentItem

Type: listitem element

Returns the last selected item in the list box, which is only useful in a multiple selection list box.

型 : listitem element

リストボックスで最後に選択された項目を返す。複数選択リストボックスでのみ役立つ。

disableKeyNavigation

Type: boolean

If this attribute is not used, the user can navigate to specific items in the list by pressing the first the first letter of the item's label. This is done incrementally, so pressing additional keys will select more specific items. This feature may be disabled for a listbox by setting this attribute to true.

型 : boolean

この属性が使われていないときには、項目のラベルの最初の文字を押すことにより、リストの特定の項目に移ることができる。これはインクリメンタルに行われるため、さらにキーを押すとより特定した項目を選択する。この属性を true に設定すると、リストボックスに対してこの機能を無効にすることができる。

disabled

Type: boolean

Gets and sets the value of the disabled attribute.

型 : boolean

disabled 属性の値を取得・設定する。

ensureElementIsVisible ( element )

Return Type: no return value

If the element in the list box is not currently visible to the user, the list box view is 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 list box view is 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 in the list box. This is not the same as the first row. If the view of the list box has been scrolled down, the function can be used to retrieve the index of the first row that the user can see.

戻り値の型 : integer

リストボックスで最初に表示されている行のインデクスを返す。これは最初の行と同じではない。リストボックスのビューが下にスクロールされたとき、ユーザが見ることのできる最初の行のインデクスを得るのにこの関数を使用することができる。

getIndexOfItem ( item )

Return Type: integer

Returns the zero-based position of the given item. Items are numbered starting from the first item displayed in the list.

戻り値の型 : integer

与えた項目のゼロベースでの位置を返す。項目は、リストで表示されている最初の項目から数え始める。

getItemAtIndex ( index )

Return Type: listitem element

Returns the item that is at the position specified by the parameter index in the list box.

戻り値の型 : listitem element

パラメータ index で指定した位置にある、リストボックスの項目を返す。

getNextItem ( startItem, delta )

Return Type: listitem element

This method returns a item after another one. The parameter startItem is the item and delta is the number of items to count to.

getNextItem ( someItem, 2 );

This example, given a item someItem, will return the item 2 rows after it, or null if no such item exists.

戻り値の型 : listitem element

このメソッドは、ある項目より後ろの項目を返す。パラメータ startItem は項目で、 delta は数える項目数である。

getNextItem ( someItem, 2 );

項目 someItem を与えたこの例は、その 2 行後の項目を返す。または項目が存在しないときには null を返す。

getNumberOfVisibleRows ( )

Return Type: integer

Returns the number of rows of the list box that are currently visible to the user.

戻り値の型 : integer

リストボックスで、現在ユーザに表示されている行数を返す。

getPreviousItem ( startItem, delta )

Return Type: listitem element

This method returns a item before another one. The parameter startItem is the item and delta is the number of items to count to.

getPreviousItem ( someItem, 5 );

This example, given a item someItem, will return the item 5 rows before it, or null if no such item exists.

戻り値の型 : listitem element

このメソッドは、ある項目より前の項目を返す。パラメータ startItem は項目で、 delta は数える項目数である。

getPreviousItem ( someItem, 5 );

項目 someItem を与えたこの例は、その 5 行前の項目を返す。または項目が存在しないときには null を返す。

getRowCount ( )

Return Type: integer

Returns the total number of rows in the list box, regardless of how many rows are displayed.

戻り値の型 : integer

リストボックスの全行数を返す。表示されている行数には関係しない。

getSelectedItem ( index )

Return Type: listitem element

When multiple items are selected, you can retrieve each selected item using this function. The argument index specifies the index in the list of selected items, not the row number of the item. Thus, getSelectedItem(7) will return the seventh selected item.

戻り値の型 : listitem element

複数項目を選択中であれば、この関数を使って各選択項目を得ることができる。引数の index は選択中の項目のリストのインデクスを指定するのであって、項目の行番号ではない。そのため、 getSelectedItem(7) は 7 番目に選択されている項目を返す。

insertItemAt ( index, label , value )

Return Type: listitem element

Creates a new listitem element and inserts it at a specific position in the list box. You may optionally set a value. The function returns the new item.

戻り値の型 : listitem element

新しい listitem 要素を作成し、リストボックスの指定した位置に挿入する。オプションとして値を設定することができる。この関数は新しい項目を返す。

invertSelection ( )

Return Type: no return value

Reverses the selected state of all the items. Selected items become deselected and deselected items become selected.

戻り値の型 : 戻り値なし

全項目の選択状態を逆にする。選択中の項目は解除され、選択されていない項目は選択される。

listBoxObject

Type: nsIListBoxObject

The nsIListBoxObject behind the list box. This property is read-only. Most of the features of the list box object are already available directly in the listbox, so you will rarely have need to use this box object directly.

型 : nsIListBoxObject

nsIListBoxObject はリストボックスの後ろにあるものである。このプロパティは読み込み専用である。リストボックスオブジェクトの機能のほとんどは既にリストボックスで直接利用できるため、このボックスオブジェクトを直接使用する必要はほとんどないでしょう。

removeItemAt ( index )

Return Type: listitem element

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

戻り値の型 : listitem element

リストボックスの指定したインデクスの子項目を削除する。この関数は削除した項目を返す。

removeItemFromSelection ( item )

Return Type: no return value

Deselects the given item without deselecting other items.

戻り値の型 : 戻り値なし

他の項目は選択解除せずに、指定した項目を解除する。

scrollToIndex ( index )

Return Type: no return value

Scrolls the list box view to the specified index. This is different than ensureIndexIsVisible because the view is always scrolled.

戻り値の型 : 戻り値なし

指定したインデクスにリストボックスのビューをスクロールする。ビューは常にスクロールされるため、これは ensureIndexIsVisible とは異なる。

selType

Gets and sets the value of the seltype attribute.

seltype 属性の値を取得・設定する。

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

戻り値の型 : 戻り値なし

引数として指定した 2 つの項目間にある項目を選択する。開始と終了の項目も選択に含まれる。他の項目は全て解除される。このメソッドは、単一選択リストボックスでは何もしない。選択が終了した後、選択イベントが送信される。

selectedCount

Type: integer

Returns the number of items that are currently selected.

型 : integer

現在選択中の項目の数を返す。

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.

型 : integer

現在選択中の項目のインデクスを返す。インデクスをこのプロパティに割り当てると、その項目を選択することができる。このプロパティに -1 を割り当てると、全項目が選択解除される。

selectedItem

Type: listitem element

Returns the currently selected item. If there are multiple items selected, the property will hold only the first selected item. To get all of the selected items, use the selectedItems property. You may select an item by assigning a listitem element to this property. All other items will be deselected.

型 : listitem element

現在選択中の項目を返す。複数項目が選択されている場合、このプロパティは最初に選択された項目のみを持つ。選択中の全項目を取得するには、 selectedItems プロパティを使用する。このプロパティに listitem 要素を割り当てると、その項目を選択することができる。他の項目は全て解除される。

selectedItems

Type: array of listitems

Returns an array of the selected items in the list.

型 : array of listitems

リストで選択中の項目の配列を返す。

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.

戻り値の型 : 戻り値なし

引数 timeout で与えたミリ秒数の後、引数 item で指定した項目を選択する。他の項目は全て解除される。

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.

戻り値の型 : 戻り値なし

指定した項目が選択されていると、解除される。選択されていないと、選択される。リストボックスの他の選択されている項目は影響を受けず、選択されたままである。

value

Type: string

Gets and sets the value of the value attribute.

型 : string

value 属性の値を取得・設定する。


Copyright (C) 1999 - 2004 XulPlanet.com