next up previous contents
Next: The context menu Up: Using menus Previous: Using menus   Contents


The main menu

The applications built by SWFKit have no main menus. But you can assign one for them by calling the "setMenu" method of the "Menu" object.

menu = new Menu;
menu.load("main");
menu.setMenu();

When a menu item in the main menu is clicked, the "onCommand" event fires.

menu = new Menu;
menu.load("main");
menu.setMenu();
menu.onCommand = function (id)
{
    if (id == "new")
    {
        // do something
    }
}

SWFKit will pass the identifier of the menu item to the event handler. So you must assign an unique identifier for each menu item, or you cannot distinguish which one is clicked.

The menu items can have shortcuts, you can set the "enableAccel" property of the menu object to true to enable the shortcuts.



Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.