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


Back to Menu.Tray Class Summary

Availability
Windows

Usage
mdm.Menu.Tray.onTrayMenuClick:Function

Parameters
None

Returns
Nothing

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

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.Tray will have "name" property available at path:
event.data.name
"name" property will correspond to name of tray 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.Tray.onTrayMenuClick = onTrayMenuClickHandler;
// or: mdm.Menu.Tray.addEventListener("onTrayMenuClick", onTrayMenuClickHandler);
// create menu items
mdm.Menu.Tray.showIcon();
mdm.Menu.Tray.insertItem(openFileMenuItem);
mdm.Menu.Tray.insertItem(closeFileMenUItem);
mdm.Menu.Tray.insertDivider();
mdm.Menu.Tray.insertItem(exitMenuItem);

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

mdm.Menu.Tray 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