Button

A button that can be pressed by the user. Event handlers can be used to trap mouse, keyboard and other events. It is typically rendered as a grey outset rectangle. You can specify the label of the button using the label attribute or by placing content inside the button.

More information about button

Example:

    <button label="Press Me"
            oncommand="alert('You pressed me!'); return false;"/>

ボタンは利用者により押されるものである。マウス、キーボード、その他のイベントを受け取るためにイベントハンドラを利用することができる。通例、ボタンは灰色に影がつけられた矩形に描画される。ボタンのラベルは label 属性を利用するか、あるいは button 要素の内容に記す。

button の追加情報

例 :

    <button label="Press Me"
            oncommand="alert('You pressed me!'); return false;"/>

属性:

accesskey autoCheck checkState checked command
crop dir disabled dlgType group
image label open orient tabindex
type

プロパティとメソッド:

accessKey accessible autoCheck checkState checked
command crop dir disabled dlgType
group image label open orient
type

属性:

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

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

型 : character

ショートカットキーとして使う文字に設定する。この文字は、ボタンのラベルテキストに現れる文字の一つである必要がある。この文字は一般に下線付きで表示される。一方、その振る舞いはプロットフォームやテーマに依存する。ユーザが ALT (またはプラットフォームによる同様のキー) とアクセスキーを押すと、ウィンドウのどこからでもボタンは起動される。この値は文字の大小には関しないが、ラベルに両方がある場合には、accesskey 属性にマッチする方の文字が使用される。

autoCheck

Type: boolean

If this attribute is true, or left out, the checked state of the button will be switched each time the button is pressed. If this attribute is false, the checked state must be adjusted manually.

型 : boolean

この属性が true のとき、あるいはこの属性がないときには、ボタンが押されるたびにボタンのチェック状態が切り替わる。この属性が false のときは、手動でチェック状態を調整する必要がある。

checkState

Type: integer: 0, 1 or 2

This attribute may be used to create three state buttons, numbered 0, 1 and 2. When in state 0 or 1, pressing the button will switch to the opposite state. When in state 2, pressing the button will switch to state 0. This means that the button acts like a checkbox except that there is a third state which must be set manually by adjusting the check state. If you wish to have different behavior for how the states are adjusted, set the autoCheck attribute to false and adjust the state with a script. The type attribute must be set to 'checkbox' for buttons with a check state. Constants for the possible values for this attribute are in the nsIDOMXULButtonElement interface.

型 : integer: 0, 1 or 2

この属性は 3 つの状態ボタン、番号 0、1、2 を作り出すのに使うことができる。状態 0 または 1 のときは、ボタンを押すと反対の状態に切り替わる。状態 2 のときには、ボタンを押すと状態 0 に切り替わる。これは、このボタンはチェックボックスのように動作することを意味している。チェック状態を調節するためには、存在する 3 つの状態を手動で設定する必要があることを除いて。状態をどのように調節するかについて異なる振る舞いを持ちたい場合には、autoCheck 属性を false に設定し、スクリプトで状態を調節する。チェック状態を持つボタンでは、type 属性を 'checkbox' に設定する必要がある。この属性に使用可能な値の定数は nsIDOMXULButtonElement インタフェースにある。

checked

Type: boolean

Indicates whether the button is checked or not.

型 : boolean

ボタンがチェックされているかどうかを表す。

command

型 : element id

Set to an id of a command element that is being observed by the element.

Type: 要素 id

要素が監視している command 要素の id を設定。

crop

Type: one of the values below

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

  • start: The text will be cropped on its left side.
  • end: The text will be cropped on its right side.
  • left: (Deprecated) The text will be cropped on its left side.
  • right: (Deprecated) The text will be cropped on its right side.
  • center: The text will be cropped on both sides.
  • none: The text will be not be cropped using an ellipsis. However, the text will simply be cut off if it is too large. The side depends on the CSS text alignment.

型 : 以下の値の一つ

与えられたスペースが小さくてボタンのラベルがその場所に合わないとき、crop 属性で指定した側にテキストは切り取られる。切り取られたテキストの位置には、省略記号が用いられる。ボックスの方向が逆のときは、切り取りも逆になる。

  • start: テキストの左側が切り取られる。
  • end: テキストの右側が切り取られる。
  • left: (非推奨) テキストの左側が切り取られる。
  • right: (非推奨) テキストの右側が切り取られる。
  • center: テキストの両側が切り取られる。
  • none: テキストの切り取りに省略記号が用いられない。テキストが非常に大きいときには、単に切られるだけである。側は CSS のテキスト配置 (alignment) に依存する。
dir

Type: one of the values below

Specifies which side of the button's label that its image is placed.

  • normal: The image appears to the left or above the label.
  • reverse: The image appears to the right or below the label.

型 : 以下の値の一つ

ボタンのラベルのどちら側に画像を置くか指定する。

  • normal: 画像はラベルの左または上に表示する。
  • reverse: 画像はラベルの右または下に表示する。
disabled

Type: boolean

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

型 : boolean

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

dlgType

Type: one of the values below

The dialog type of the button, used only when the button is in a dialog box. You can use this feature to replace the standard dialog box buttons with custom buttons, yet the dialog event methods will still function. For example, if the dlgType is set to 'accept', the button will replace the dialog box's accept button, which is usually labeled OK. Using this attribute on a button that is not in a dialog box has no effect. The following values can be used as the dialog type:

  • accept: The OK button, which will accept the changes when pressed.
  • cancel: The cancel button which will cancel the operation.
  • help: A help button for displaying help about the dialog.
  • disclosure: A button to show more information. This might be a button or a disclosure triangle.

型 : 以下の値の一つ

ボタンのダイアログタイプ。ボタンがダイアログボックスのボタンのときにのみ使われる。標準のダイアログボックスボタンをカスタムボタンで置きかえることに、この機能が使える。こうすると、ダイアログのイベントメソッドが働く。例えば、dlgType を 'accept' に設定した場合、ボタンはダイアログボックスの accept ボタン (通常は OK というラベルになっている) を置きかえます。ダイアログボックスにないボタンでこの属性を使っても、何の効果もありません。以下の値がダイアログタイプとして使用できる。

  • accept: OK ボタン。押されたときに変更を受け入れる。
  • cancel: キャンセルボタン。操作をキャンセルする。
  • help: ヘルプボタン。ダイアログについてのヘルプを表示する。
  • disclosure: 詳細情報を表示するボタン。ボタンかまたは穴の空いた三角形で表示される。
group

Type: string group name

Buttons with the same value for their group attribute are put into the same group. Only one button from each group can be checked at a time. If the user selects one the radio buttons, the others in the group are unchecked.

型 : string group name

group 属性に同じ値を持つボタンは、同じグループに入れられる。各グループでは 1 つのボタンのみが一時にチェックされる。ユーザがラジオボタンの一つを選択したとき、そのグループの他のボタンはチェックを解除される。

image

Type: image URL

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

型 : image URL

ボタンに表示する画像の URL。この属性がないときには、画像は表示されない。画像の位置は dir 属性と orient 属性で決定される。

label

Type: string

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

型 : 文字列

ボタンに表示するラベル。この属性がないときには、テキストは表示されない。

open

型 : boolean

For the menu type buttons, the open attribute is set to true when the menu is open. The open attribute is not present if the menu is closed.

Type: boolean

メニュータイプのボタンのとき、メニューが開いていると open 属性は true に設定される。メニューが閉じているときは、open 属性は存在しない。

orient

Type: one of the values below

Along with the dir attribute, the orient attribute is used to indicate where the button's image appears in relation to the the label.

  • horizontal: The image appears to the left of the label if the direction is 'normal' or to the right of the text if the direction is 'reverse'.
  • vertical: The image appears above the label if the direction is 'normal' or below the text if the direction is 'reverse'.

型 : 以下の値の一つ

dir 属性とともに用い、ボタンの画像がラベルとの関係で表示される場所を示すのにorient 属性を使う。

  • horizontal: 方向が 'normal' のとき、画像はラベルの左側に表示される。方向が 'reverse' のときはテキストの右側に表示される。
  • vertical: 方向が 'normal' のとき、画像はラベルの上側に表示される。方向が 'reverse' のときはテキストの下側に表示される。
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

要素のタブ順序。タブ順序とは、ユーザが Tab キーを押したときにフォーカスが移動する順番のこと。高い tabindex を持つ要素が、タブ順序のシーケンスで後になる。

type

Type: one of the values below

The type of button. If this attribute is not present, a normal button is created. Leave the attribute out for a normal button.

  • checkbox: This type of button can be in two states. The user can click the button to switch between the states. This is not the same as a checkbox because it looks like a button.
  • menu: Set the type attribute to the value 'menu' to create a button with a menu popup. Place a menupopup element inside the button in this case. The user may click anywhere on the button to open and close the menu.
  • menu-button: You can also use the value 'menu-button' to create a button with a menu. Unlike the 'menu' type, this type requires the user to press the arrow to open the menu, but a different command may be invoked when the main part of the button is pressed.
  • radio: The button acts like a radio button. Only one button in the group can be on a once.

型 : 以下の値の一つ

ボタンのタイプ。この属性がない場合は、普通のボタンが作成される。普通のボタンにするには、この属性を取り除くこと。

  • checkbox: このタイプのボタンは 2 つの状態を取ることができる。ユーザはボタンをクリックして、その状態間を切り替えることができる。ボタンの外形をとるため、これは checkbox 要素と同じではない。
  • menu: type 属性を 'menu' に設定すると、メニューポップアップを持つボタンを作成する。この場合にはボタン内に menupopup 要素を置くことができる。 ボタンのどこをクリックしても、メニューを開いたり閉じたりできる。
  • menu-button: 'menu-button' 値を使うと、メニューを持つボタンを作成できる。'menu' 型とは違い、この型ではメニューを開くにはユーザが矢印を押す必要があり、ボタンの主部が押された場合は異なるコマンドが実行される。
  • radio: ボタンはラジオボタンのように動作する。グループ内の 1 つのボタンだけが一度にオンになれる。

プロパティとメソッド:

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

accessKey

Type: character

Gets and sets the value of the accesskey attribute.

型 : character

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

accessible

Type: nsIAccessible

Returns the accessibility object for the button.

型 : nsIAccessible

ボタンの accessibility オブジェクトを返す。

autoCheck

Type: boolean

Gets and sets the value of the autoCheck attribute.

型 : boolean

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

checkState

Type: integer: 0, 1 or 2

Gets and sets the value of the checkState attribute.

型 : integer: 0, 1 or 2

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

checked

Type: boolean

Gets and sets the value of the checked attribute.

型 : boolean

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

command

Type: element id

Gets and sets the value of the command attribute.

型 : 要素 id

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

crop

Type: string

Gets and sets the value of the crop attribute.

型 : 文字列

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

dir

Type: string

Gets and sets the value of the dir attribute.

型 : 文字列

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

disabled

Type: boolean

Gets and sets the value of the disabled attribute.

型 : boolean

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

dlgType

Type: string

Gets and sets the value of the dlgType attribute.

型 : 文字列

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

group

Type: string group name

Gets and sets the value of the group attribute.

型 : string group name

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

image

Type: image URL

Gets and sets the value of the image attribute.

型 : image URL

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

label

Type: string

Gets and sets the value of the label attribute.

型 : 文字列

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

open

Type: boolean

Gets and sets the value of the open attribute.

型 : boolean

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

orient

Type: string

Gets and sets the value of the orient attribute.

型 : 文字列

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

type

Type: string

Gets and sets the value of the type attribute.

型 : 文字列

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


Copyright (C) 1999 - 2004 XulPlanet.com