FlexNativeMenu Control in Flex4

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

 
 

Share on Google+Share on Google+

FlexNativeMenu Control in Flex4

Ads

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"/>

<menuitem type="separator"/>

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

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

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

</menuitem>

<menuitem label="View"/>

<menuitem label="Document"/>

<menuitem label="Tools">

<menuitem label="BasicToolsSubToolBar">

<menuitem label="SelectMenuItem"/>

<menuitem label="HandMenuItem"/>

<menuitem label="ZoominMenuItem"/>

<menuitem label="ZoomDragMenuItem"/>

</menuitem>

<menuitem type="separator"/>

<menuitem label="AnalysisToolsItem"/>

</menuitem>

<menuitem label="Window"/>

<menuitem label="Help"/>

</root>

</fx:XML>

</fx:Declarations>

</s:WindowedApplication>

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

Output:

Download this code

Advertisements

Ads

Posted on: May 25, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles