O'Reilly logo

Adobe AIR 1.5 Cookbook by Koen De Weggheleire, Koen DeWeggheleire, Marco Casario, David Tucker, Rich Tretola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 12. Application and Window Native Menus

Operating systems provide facilities for creating menus; these menus are called native menus. Adobe AIR supports working with native menus, and the recipes in this chapter show you how to build several types of native menus. At this writing, AIR supports application, window, context, and pop-up menus. Application and window menus serve the same purpose but on different platforms. Specifically, window menus are available only on Windows, and application menus are available only on Macs. Computer users are familiar with the typical native menus, so the usability of your AIR application improves a lot when you offer users application or window menus.

To create native menus, the Adobe AIR classes to use are flash.display.NativeMenu and flash.display.NativeMenuItem.

To create context menus, you can also use the classes flash.ui.ContextMenu and flash.ui.ContextMenuItem.

Note

AIR enables you to create system tray and Dock icon menus as well. See Chapter 13 for more information on these custom taskbar and Dock menus.

Creating a Native Menu

Problem

You want to create a menu for your AIR application and present the menu as an application menu or window menu depending on the user’s operating system.

Solution

Use the NativeMenu constructor to create the base menu, attach child NativeMenuItem objects, and then set the top-level base menu as the menu for the AIR application or window depending on your preference or the operating system.

Discussion

When working ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required