XUL:command
出典: MDC
« XUL リファレンス HOME [ 例 | 属性 | プロパティ | メソッド | 関連項目 ]
command 要素は複数のソースから操作を呼び出すのに使われます。例えば、クリップボードの貼り付け操作は編集メニューやコンテクストメニュー、キーボードショートカットによって呼び出されます。oncommand 属性を使ってコマンドをコードに追加します。ユーザにどのように呼び出されてもそれは呼ばれるでしょう。さらに、command を無効にすると自動的にメニューアイテムとキーボードショットカットも無効になります。
command は id によって識別されます。chrome://global/content/globalOverlay.js スクリプトをウィンドウに含めると、command を呼び出す goDoCommand 関数を使うことができます。この関数を使うことの利点は、command が応答する UI の部分にも送られることです。特に、これは現在フォーカスされている要素になるでしょう。
broadcaster と同じように、commands は他の要素に属性を転送します。
詳しい情報は XUL チュートリアルにあります。参照: command 属性, commandset 要素
- 属性
- disabled, label, oncommand
以下のコードは貼り付けコマンド (cmd_paste) を現在フォーカスのある要素に送ります:
goDoCommand("cmd_paste");
二つのボタンの例
<command id="cmd_openhelp" oncommand="alert('Help');"/>
<button label="Help" command="cmd_openhelp"/>
<button label="More Help" command="cmd_openhelp"/>
[編集] 属性
|
XUL 要素からの継承
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
- 型: 真偽値
- 要素が無効化されているかどうかを示します。ある要素が
true に設定されていたら、その要素は無効化されています。無効化された要素は通常グレイ表示のテキストで描画されます。要素が無効化されていると、ユーザのアクションには応答せず、フォーカスもあてられず、command イベントも発生しません。
- label
- 型: string
- 要素上に表示するlabel。 省略された場合、テキストは表示されない。
- oncommand
- 型: script code
- このイベントハンドラは command が活性化した時、呼び出されます。これは、ユーザがメニュー項目を選択したり command に割り当てられたキーボードショートカットが押下された場合に起こります。
[編集] プロパティ
|
XUL 要素からの継承
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
DOM 要素からの継承
attributes,
childNodes,
cloneNode,
firstChild,
lastChild,
localName,
namespaceURI,
nextSibling,
nodeName,
nodeType,
nodeValue,
ownerDocument,
parentNode,
prefix,
previousSibling,
tagName
|
[編集] メソッド
|
XUL 要素からの継承
blur,
click,
doCommand,
focus,
getElementsByAttribute
DOM 要素からの継承
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
|
[編集] 関連項目