パッケージflash.events
クラスpublic class ContextMenuEvent
継承ContextMenuEvent Inheritance Event Inheritance Object

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

ユーザーがコンテキストメニューを生成または使用すると、Flash® Player によって ContextMenuEvent オブジェクトが送出されます。ユーザーは、ユーザーのポインティングデバイス (通常はマウスまたはトラックボール) の小さなボタンをクリックすることにより、コンテキストメニューを生成します。次の 2 種類の ContextMenuEvent オブジェクトがあります。

例を表示

関連項目

ContextMenu クラス
ContextMenuItem クラス


パブリック プロパティ
 プロパティ定義元
 Inheritedbubbles : Boolean
[read-only] イベントがバブリングイベントかどうかを示します。
Event
 Inheritedcancelable : Boolean
[read-only] イベントに関連付けられた動作を回避できるかどうかを示します。
Event
 Inheritedconstructor : Object
特定のオブジェクトインスタンスのクラスオブジェクトまたはコンストラクタ関数への参照です。
Object
  contextMenuOwner : InteractiveObject
メニューが関連付けられる表示リストオブジェクトです。
ContextMenuEvent
 InheritedcurrentTarget : Object
[read-only] イベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
Event
 InheritedeventPhase : uint
[read-only] イベントフローの現在の段階です。
Event
  mouseTarget : InteractiveObject
ユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。
ContextMenuEvent
 Inheritedprototype : Object
[static] クラスまたは関数オブジェクトのプロトタイプオブジェクトへの参照です。
Object
 Inheritedtarget : Object
[read-only] イベントターゲットです。
Event
 Inheritedtype : String
[read-only] イベントのタイプです。
Event
パブリック メソッド
 メソッド定義元
  
ContextMenuEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, mouseTarget:InteractiveObject = null, contextMenuOwner:InteractiveObject = null)
メニューイベントに関する特定の情報を含む Event オブジェクトを作成します。
ContextMenuEvent
  
ContextMenuEvent オブジェクトのコピーを作成して、各プロパティの値を元のプロパティの値と一致するように設定します。
ContextMenuEvent
 Inherited
formatToString(className:String, ... arguments):String
カスタム Event クラスに toString() メソッドを実装するためのユーティリティ関数です。
Event
 Inherited
オブジェクトに指定されたプロパティが定義されているかどうかを示します。
Object
 Inherited
イベントで preventDefault() が呼び出されたかどうかを確認します。
Event
 Inherited
Object クラスのインスタンスが、パラメータとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。
Object
 Inherited
イベントのデフォルトの動作をキャンセルできる場合に、その動作をキャンセルします。
Event
 Inherited
指定されたプロパティが存在し列挙できるかどうかを示します。
Object
 Inherited
ループ処理に対するダイナミックプロパティの可用性を設定します。
Object
 Inherited
イベントフローの現在のノードおよび後続するノードで、イベントリスナーが処理されないようにします。
Event
 Inherited
イベントフローの現在のノードに後続するノードで、イベントリスナーが処理されないようにします。
Event
  
ContextMenuEvent オブジェクトのすべてのプロパティを含むストリングを返します。
ContextMenuEvent
 Inherited
指定されたオブジェクトのプリミティブな値を返します。
Object
パブリック 定数
 定数定義元
 InheritedACTIVATE : String = "activate"
[static] activate イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedADDED : String = "added"
[static] added イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedADDED_TO_STAGE : String = "addedToStage"
[static] addedToStage イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedCANCEL : String = "cancel"
[static] cancel イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedCHANGE : String = "change"
[static] change イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedCLOSE : String = "close"
[static] close イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedCOMPLETE : String = "complete"
[static] complete イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedCONNECT : String = "connect"
[static] connect イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedDEACTIVATE : String = "deactivate"
[static] deactivate イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedENTER_FRAME : String = "enterFrame"
[static] enterFrame イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedFULLSCREEN : String = "fullScreen"
[static] fullScreen イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedID3 : String = "id3"
[static] id3 イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedINIT : String = "init"
[static] init イベントオブジェクトの type プロパティの値を定義します。
Event
  MENU_ITEM_SELECT : String = "menuItemSelect"
[static] menuItemSelect イベントオブジェクトの type プロパティ値を定義します。
ContextMenuEvent
  MENU_SELECT : String = "menuSelect"
[static] menuSelect イベントオブジェクトの type プロパティ値を定義します。
ContextMenuEvent
 InheritedMOUSE_LEAVE : String = "mouseLeave"
[static] mouseLeave イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedOPEN : String = "open"
[static] open イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedREMOVED : String = "removed"
[static] removed イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedREMOVED_FROM_STAGE : String = "removedFromStage"
[static] removedFromStage イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedRENDER : String = "render"
[static] render イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedRESIZE : String = "resize"
[static] resize イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedSCROLL : String = "scroll"
[static] scroll イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedSELECT : String = "select"
[static] select イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedSOUND_COMPLETE : String = "soundComplete"
[static] soundComplete イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedTAB_CHILDREN_CHANGE : String = "tabChildrenChange"
[static] tabChildrenChange イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedTAB_ENABLED_CHANGE : String = "tabEnabledChange"
[static] tabEnabledChange イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedTAB_INDEX_CHANGE : String = "tabIndexChange"
[static] tabIndexChange イベントオブジェクトの type プロパティ値を定義します。
Event
 InheritedUNLOAD : String = "unload"
[static] unload イベントオブジェクトの type プロパティ値を定義します。
Event
プロパティの詳細
contextMenuOwnerプロパティ
contextMenuOwner:InteractiveObject  [read-write]

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

メニューが関連付けられる表示リストオブジェクトです。これは、マウスターゲット (mouseTarget)、または表示リストの祖先のいずれかになります。


実装
    public function get contextMenuOwner():InteractiveObject
    public function set contextMenuOwner(value:InteractiveObject):void
mouseTargetプロパティ 
mouseTarget:InteractiveObject  [read-write]

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

ユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。これは、メニューが関連付けられている表示リストオブジェクト (contextMenuOwner)、またはその表示リストの子孫のいずれかになります。


実装
    public function get mouseTarget():InteractiveObject
    public function set mouseTarget(value:InteractiveObject):void
コンストラクタの詳細
ContextMenuEvent()コンストラクタ
public function ContextMenuEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, mouseTarget:InteractiveObject = null, contextMenuOwner:InteractiveObject = null)

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

メニューイベントに関する特定の情報を含む Event オブジェクトを作成します。イベントリスナーには Event オブジェクトがパラメータとして渡されます。

パラメータ
type:String — イベントのタイプです。有効な値は次のとおりです。
  • ContextMenuEvent.MENU_ITEM_SELECT
  • ContextMenuEvent.MENU_SELECT
 
bubbles:Boolean (default = false) — Event オブジェクトがイベントフローのバブリング段階で処理されるかどうかを判断します。イベントリスナーは、継承された bubbles プロパティを通じてこの情報にアクセスできます。
 
cancelable:Boolean (default = false) — Event オブジェクトがキャンセル可能かどうかを判断します。イベントリスナーは、継承された cancelable プロパティを通じてこの情報にアクセスできます。
 
mouseTarget:InteractiveObject (default = null) — ユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。これは、contextMenuOwner または、その表示リストの子孫のいずれかになります。
 
contextMenuOwner:InteractiveObject (default = null) — メニューが関連付けられる表示リストオブジェクトです。これは、mouseTarget または、その表示リストの祖先のいずれかになります。

関連項目

メソッドの詳細
clone()メソッド
public override function clone():Event

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

ContextMenuEvent オブジェクトのコピーを作成して、各プロパティの値を元のプロパティの値と一致するように設定します。

戻り値
Event — 元のオブジェクトと同じプロパティ値を含む新しい ContextMenuEvent オブジェクトです。
toString()メソッド 
public override function toString():String

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

ContextMenuEvent オブジェクトのすべてのプロパティを含むストリングを返します。ストリングは次の形式です。

[ContextMenuEvent type= value bubbles= value cancelable= value ... contextMenuOwner= value ]

戻り値
String — ContextMenuEvent オブジェクトのすべてのプロパティを含むストリングです。
定数の詳細
MENU_ITEM_SELECT定数
public static const MENU_ITEM_SELECT:String = "menuItemSelect"

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

type プロパティ (menuItemSelect イベントオブジェクト) の値を定義します。

このイベントには、次のプロパティがあります。

プロパティ
bubblesfalse
cancelablefalse は、キャンセルするデフォルトの動作がないことを示します。
contextMenuOwnerメニューが関連付けられる表示リストオブジェクトです。
currentTargetイベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
mouseTargetユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。
target選択された ContextMenuItem オブジェクトです。target は、必ずしもイベントリスナーを登録した表示リスト内のオブジェクトとは限りません。現在イベントを処理している表示リスト内のオブジェクトにアクセスするには、currentTarget プロパティを使用します。

関連項目

MENU_SELECT定数 
public static const MENU_SELECT:String = "menuSelect"

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

type プロパティ (menuSelect イベントオブジェクト) の値を定義します。

このイベントには、次のプロパティがあります。

プロパティ
bubblesfalse
cancelablefalse は、キャンセルするデフォルトの動作がないことを示します。
contextMenuOwnerメニューが関連付けられる表示リストオブジェクトです。
currentTargetイベントリスナーで Event オブジェクトをアクティブに処理しているオブジェクトです。
mouseTargetユーザーがコンテキストメニューを表示するために右クリックした表示リストオブジェクトです。
target表示される ContextMenu オブジェクトです。target は、必ずしもイベントリスナーを登録した表示リスト内のオブジェクトとは限りません。現在イベントを処理している表示リスト内のオブジェクトにアクセスするには、currentTarget プロパティを使用します。

関連項目

例の使用法
ContextMenuEventExample.as

次の例では、ContextMenuEventExample クラスを使用して、デフォルトのコンテキストメニューアイテムをステージから削除し、ステージ上の四角形の色を変更する新しいメニューアイテムを追加します。この例では、次の処理を実行します。
  1. myContextMenu プロパティが宣言され、新しい ContextMenu オブジェクトに割り当てられ、Sprite 型の redRectangle プロパティが宣言されます。
  2. removeDefaultItems() メソッドが呼び出されます。このメソッドによって、すべてのビルトインコンテキストメニューアイテムが削除されます。ただし、プリントを除きます。
  3. addCustomMenuItems() メソッドが呼び出されます。このメソッドによって、Reverse Colors メニューアイテムが defaultItems 配列に配置されます。配列の push() メソッドが使用されます。menuItemSelect イベントリスナーが ContextMenuItem オブジェクトに追加され、関連付けられるメソッドは menuItemSelectHandler() という名前です。このメソッドは、ユーザーがコンテキストメニューから [色の反転] を選択すると必ず trace() ステートメントを出力します。また、赤い四角形は黒に変わり、黒のテキストは赤に変わります。
  4. コンストラクタに戻り、menuSelect イベントリスナーが、関連するメソッド menuSelectHandler() と共に追加されます。このメソッドは、コンテキストメニューのアイテムが選択されるたびに 3 つの trace() ステートメントを出力します。
  5. コンストラクタは addChildren() を呼び出します。これは、赤色の四角形を描画し、その四角形を表示リストに追加します。この四角形は、表示リストにすぐに表示されます。
  6. 最後に、myContextMenuredRectangle プロパティのコンテキストメニューに割り当てられます。このため、カスタムコンテキストメニューが表示されるのは、マウスポインタが四角形の上にある場合のみです。
package {
    import flash.ui.ContextMenu;
    import flash.ui.ContextMenuItem;
    import flash.ui.ContextMenuBuiltInItems;
    import flash.events.ContextMenuEvent;
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.text.TextField;

    public class ContextMenuEventExample extends Sprite {
        private var myContextMenu:ContextMenu;
        private var menuLabel:String = "Reverse Colors";
        private var textLabel:String = "Right Click";
        private var redRectangle:Sprite;
        private var label:TextField;
        private var size:uint = 100;
        private var black:uint = 0x000000;
        private var red:uint = 0xFF0000;

        public function ContextMenuEventExample() {
            myContextMenu = new ContextMenu();
            removeDefaultItems();
            addCustomMenuItems();
            myContextMenu.addEventListener(ContextMenuEvent.MENU_SELECT, menuSelectHandler);

            addChildren();
            redRectangle.contextMenu = myContextMenu;
        }

        private function addChildren():void {
            redRectangle = new Sprite();
            redRectangle.graphics.beginFill(red);
            redRectangle.graphics.drawRect(0, 0, size, size);
            addChild(redRectangle);
            redRectangle.x = size;
            redRectangle.y = size;
            label = createLabel();
            redRectangle.addChild(label);
        }

        private function removeDefaultItems():void {
            myContextMenu.hideBuiltInItems();
            var defaultItems:ContextMenuBuiltInItems = myContextMenu.builtInItems;
            defaultItems.print = true;
        }

        private function addCustomMenuItems():void {
            var item:ContextMenuItem = new ContextMenuItem(menuLabel);
            myContextMenu.customItems.push(item);
            item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, menuItemSelectHandler);
        }

        private function menuSelectHandler(event:ContextMenuEvent):void {
            trace("menuSelectHandler: " + event);
        }

        private function menuItemSelectHandler(event:ContextMenuEvent):void {
            trace("menuItemSelectHandler: " + event);
            var textColor:uint = (label.textColor == black) ? red : black;
            var bgColor:uint = (label.textColor == black) ? black : red;
            redRectangle.graphics.clear();
            redRectangle.graphics.beginFill(bgColor);
            redRectangle.graphics.drawRect(0, 0, size, size);
            label.textColor = textColor;
        }

        private function createLabel():TextField {
            var txtField:TextField = new TextField();
            txtField.text = textLabel;
            return txtField;
        }
    }
}




 

このページに新しいコメントが追加された場合に、電子メールでの通知を希望する。 | コメントレポート

現在のページ: http://livedocs.adobe.com/flash/9.0_jp/ActionScriptLangRefV3/flash/events/ContextMenuEvent.html