blob: c86913eca1b7e75a6d793d215fd7d1278c3bd58d [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.controls.Menu;
import mx.events.FlexEvent;
import mx.events.MenuEvent;
protected var myMenu:Menu;
protected function showHandler(event:MouseEvent):void
{
myMenu = Menu.createMenu(null, myMenuData, false);
myMenu.labelField="@label";
myMenu.show(90, 35);
myMenu.addEventListener(MenuEvent.CHANGE,onMenuChange);
}
protected function hideHandler(event:MouseEvent):void
{
myMenu.hide();
}
protected function onMenuChange(event:MenuEvent):void
{
lblSelected.text = event.label;
}
]]>
</fx:Script>
<fx:Declarations>
<fx:XML format="e4x" id="myMenuData">
<root>
<menuitem label="MenuItem A" >
<menuitem label="SubMenuItem A-1" enabled="false"/>
<menuitem label="SubMenuItem A-2"/>
</menuitem>
<menuitem label="MenuItem B" type="check" toggled="true"/>
<menuitem label="MenuItem C" type="check" toggled="false"/>
<menuitem type="separator"/>
<menuitem label="MenuItem D" >
<menuitem label="SubMenuItem D-1" type="radio"
groupName="one"/>
<menuitem label="SubMenuItem D-2" type="radio"
groupName="one" toggled="true"/>
<menuitem label="SubMenuItem D-3" type="radio"
groupName="one"/>
</menuitem>
</root>
</fx:XML>
</fx:Declarations>
<s:Panel title="Menu Sample" width="100%" height="100%">
<s:layout>
<s:VerticalLayout paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10"/>
</s:layout>
<s:HGroup bottom="15" horizontalCenter="0" verticalAlign="middle">
<s:Button label="Show Menu" click="showHandler(event)" />
<s:Button label="Hide Menu" click="hideHandler(event)" />
<s:Label text="Menu Item Selected:" fontWeight="bold" />
<s:Label id="lblSelected" />
</s:HGroup>
<s:Label width="220" top="15" right="50"
text="The Menu control is a pop-up control that contains a menu of individually selectable choices. You use ActionScript
to create a Menu control that pops up in response to a user action, typically as part of an event listener."/>
</s:Panel>
</s:Module>