Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

command

command 要素は複数のソースから操作を呼び出すのに使われます。例えば、クリップボードの貼り付け操作は編集メニューやコンテクストメニュー、キーボードショートカットによって呼び出されます。oncommand 属性を使ってコマンドをコードに追加します。ユーザにどのように呼び出されてもそれは呼ばれるでしょう。さらに、command を無効にすると自動的にメニューアイテムとキーボードショットカットも無効になります。

command は id によって識別されます。chrome://global/content/globalOverlay.js スクリプトをウィンドウに含めると、command を呼び出す goDoCommand 関数を使うことができます。この関数を使うことの利点は、command が応答する UI の部分にも送られることです。特に、これは現在フォーカスされている要素になるでしょう。

broadcaster と同じように、commands は他の要素に属性を転送します。

詳しい情報は XUL チュートリアルにあります。参照: command 属性, commandset 要素

属性
disabled, label, oncommand

以下のコードは貼り付けコマンド (cmd_paste) を現在フォーカスのある要素に送ります:

 // 先に chrome://global/content/globalOverlay.js を include しておいてください
 goDoCommand("cmd_paste");

二つのボタンの例

<command id="cmd_openhelp" oncommand="alert('Help');"/>
<button label="Help" command="cmd_openhelp"/>
<button label="More Help" command="cmd_openhelp"/>

属性

disabled
型: 論理型
要素が無効化されているかどうかを示します。ある要素が true に設定されていたら、その要素は無効化されています。無効化された要素は通常グレイ表示のテキストで描画されます。要素が無効化されていると、ユーザのアクションには応答せず、フォーカスもあてられず、command イベントも発生しません。

 

label
型: 文字列型
要素上に表示するlabel。 省略された場合、テキストは表示されない。
oncommand
型: スクリプトコード
このイベントハンドラは command が活性化した時、呼び出されます。これは、ユーザがメニュー項目を選択したり command に割り当てられたキーボードショートカットが押したりした場合に起こります。

プロパティ

XUL 要素からの継承
align, attributes, allowEvents, baseURI, boxObject, builder, childElementCount, childNodes, children, className, clientHeight, clientLeft, clientTop, clientWidth, collapsed, contextMenu, controllers, database, datasources, dir, firstChild, firstElementChild, flex, height, hidden, id, lastChild, lastElementChild, left, localName, maxHeight, maxWidth, menu, minHeight, minWidth, namespaceURI, nextElementSibling, nextSibling, nodeName, nodeType, nodeValue, observes, ordinal, orient, ownerDocument, pack, parentNode, persist, prefix, previousElementSibling, previousSibling, ref, resource, scrollHeight, scrollLeft, scrollTop, scrollWidth, statusText, style, tagName,textContent, tooltip, tooltipText, top, width

メソッド

関連項目

ドキュメントのタグと貢献者

 このページの貢献者: Marsf, Mgjbot, Taken
 最終更新者: Marsf,