onContextMenuClick This page was last modified over 30 day(s) ago and has 0 comment(s)


Back to Menu.Context Class Summary

Availability
Windows

Usage
mdm.Menu.Context.onContextMenuClick:Function

Parameters
None

Returns
Nothing

Description
Event "onContextMenuClick" is dispatched when the user clicks on a context menu item. The handler for event can be assigned to this method or could be added via addEventListener method of mdm.Menu.Context

Notes
There are two ways to listen for events in 4.0:
#1
using "onEventNameFunction" - callback based handlers introduced in {mdm} 2.0
#2
using IEventListener model based on Events introduced in 4.0.

No matter what implementation you would use either callback and listener handler would have to use single-argument defintion as in below sample:
// callback based handlers
mdm.Appllication.onAppChangeFocus = function(event:Event):void
{
// proceed with event
};

// handlers based on IEventListener model
function onAppChangeFocusHandler(event:Event):void
{
// proceed with event
};

The event for mdm.Menu.Context will have "name" property available at path:
event.data.name
"name" property will correspond to name of context menu item clicked

Example Code
// to efficiently handle menu items and
// to avoid typos use variable defined labels
var openFileMenuItem:String = "Open";
var closeFileMenUItem:String = "Close File";
var exitMenuItem:String = "Quit MyApplication";

// next assign handler to handle click on menu
mdm.Menu.Context.onContextMenuClick = onContextMenuClickHandler;
// or: mdm.Menu.Context.addEventListener("onContextMenuClick", onContextMenuClickHandler);
// create menu items
mdm.Menu.Context.enable();
mdm.Menu.Context.insertItem(openFileMenuItem);
mdm.Menu.Context.insertItem(closeFileMenUItem);
mdm.Menu.Context.insertDivider();
mdm.Menu.Context.insertItem(exitMenuItem);

// function will be called to handle menu events
function onContextMenuClickHandler(event:mdm.Event):void
{
switch(event.data.name)
{
case openFileMenuItem:
openFileAction();
break;
case closeFileMenUItem:
closeFileAction();
break;
case exitMenuItem:
exitAction();
break;
};
}

mdm.Menu.Context Class Example Downloads
No Example Downloads Available


Registered Users must be logged in to 'MyAccount' to add a Comment - Log In Here
  After Logging In, Click Here to Refresh This Page