FlexNativeMenu Control in Flex4


 

FlexNativeMenu Control in Flex4

The FlexNativeMenu is a MX component. It's provide a data for menu control. It has no visual representation.

The FlexNativeMenu is a MX component. It's provide a data for menu control. It has no visual representation.

FlexNativeMenu Control  in Flex4:

The FlexNativeMenu is a MX component. It's provide a data for menu control.
It has no visual representation. A FlexNativeMenu instance defines a native operating system menu such as a window menu, an application menu, a context menu etc. It used for making a menu control in AIR Application. First you will make a XML List for item and call it in a FlexNativeMenu control using dataProvider property for providing a data to the menu control . You must define a labelField="@label" property in FlexNativeMenu control tag for showing a item value in menu control. The tag of this control is <mx:FlexNativeMenu>.

Example:

<?xml version="1.0" encoding="utf-8"?>

<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:s="library://ns.adobe.com/flex/spark"

xmlns:mx="library://ns.adobe.com/flex/mx">

<s:menu>

<mx:FlexNativeMenu dataProvider="{menuItem}"

labelField="@label"

keyEquivalentField="@keyEquivalent"

showRoot="false"/>

</s:menu>

<fx:Declarations>

<fx:XML id="menuItem">

<root>

<menuitem label="File">

<menuitem label="New" keyEquivalent="n" controlKey="true"/>

<menuitem label="Open" keyEquivalent="o" controlKey="true"/>

<menuitem type="separator"/>

<menuitem label="Save" keyEquivalent="s" controlKey="true"/>

<menuitem label="Save as..."/>

<menuitem type="separator"/>

<menuitem label="Close"/>

<menuitem type="separator"/>

<menuitem label="Print" keyEquivalent="p" controlKey="true"/>

<menuitem type="separator"/>

<menuitem label="Quit"/>

</menuitem>

<menuitem label="Edit">

<menuitem label="Undo" keyEquivalent="z" controlKey="true"/>

<menuitem label="Redo" keyEquivalent="r" controlKey="true"/>

0

<menuitem type="separator"/>

<menuitem label="Cut" keyEquivalent="x" controlKey="true"/>

<menuitem label="Copy" keyEquivalent="c" controlKey="true"/>

1

<menuitem label="Paste" keyEquivalent="v" controlKey="true"/>

</menuitem>

<menuitem label="View"/>

2

<menuitem label="Document"/>

<menuitem label="Tools">

<menuitem label="BasicToolsSubToolBar">

3

<menuitem label="SelectMenuItem"/>

<menuitem label="HandMenuItem"/>

<menuitem label="ZoominMenuItem"/>

4

<menuitem label="ZoomDragMenuItem"/>

</menuitem>

<menuitem type="separator"/>

5

<menuitem label="AnalysisToolsItem"/>

</menuitem>

<menuitem label="Window"/>

6

<menuitem label="Help"/>

</root>

</fx:XML>

7

</fx:Declarations>

</s:WindowedApplication>

In this example you can see how we can use a FlexNativeMenu control  in Flex4.

8

Output:

Download this code

Ads