This is an automated email from the ASF dual-hosted git repository.
pent pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 6303d38 Adding MenuExample showing pop-up menus and MenuBar within a
Panel.
6303d38 is described below
commit 6303d38196218c804bcf9439608101895c2030c2
Author: Peter Ent <[email protected]>
AuthorDate: Mon Feb 26 16:29:48 2018 -0500
Adding MenuExample showing pop-up menus and MenuBar within a Panel.
---
examples/build.xml | 3 +
examples/royale/MenuExample/build.xml | 54 +++++++
.../MenuExample/src/main/royale/MenuExample.mxml | 36 +++++
.../MenuExample/src/main/royale/MyInitialView.mxml | 161 +++++++++++++++++++++
4 files changed, 254 insertions(+)
diff --git a/examples/build.xml b/examples/build.xml
index ea7b472..29240c7 100644
--- a/examples/build.xml
+++ b/examples/build.xml
@@ -96,6 +96,7 @@
<ant dir="${basedir}/royale/HelloWorld"/>
<ant dir="${basedir}/royale/ListExample"/>
<ant dir="${basedir}/royale/MapSearch"/>
+ <ant dir="${basedir}/royale/MenuExample"/>
<ant dir="${basedir}/royale/MobileMap"/>
<ant dir="${basedir}/royale/MobileStocks"/>
<ant dir="${basedir}/royale/MobileTrader"/>
@@ -145,6 +146,7 @@
<ant dir="${basedir}/royale/HelloWorld" target="clean"/>
<ant dir="${basedir}/royale/ListExample" target="clean"/>
<ant dir="${basedir}/royale/MapSearch" target="clean"/>
+ <ant dir="${basedir}/royale/MenuExample" target="clean"/>
<ant dir="${basedir}/royale/MobileTrader" target="clean"/>
<ant dir="${basedir}/royale/MobileStocks" target="clean"/>
<ant dir="${basedir}/royale/MobileMap" target="clean"/>
@@ -184,6 +186,7 @@
<ant dir="${basedir}/royale/HelloWorld" target="examine"/>
<ant dir="${basedir}/royale/ListExample" target="examine"/>
<ant dir="${basedir}/royale/MapSearch" target="examine"/>
+ <ant dir="${basedir}/royale/MenuExample" target="examine"/>
<ant dir="${basedir}/royale/MobileTrader" target="examine"/>
<ant dir="${basedir}/royale/MobileStocks" target="examine"/>
<ant dir="${basedir}/royale/MobileMap" target="examine"/>
diff --git a/examples/royale/MenuExample/build.xml
b/examples/royale/MenuExample/build.xml
new file mode 100644
index 0000000..c79d4f0
--- /dev/null
+++ b/examples/royale/MenuExample/build.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+
+ 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.
+
+-->
+
+
+<project name="menuexample" default="main" basedir=".">
+ <property name="ROYALE_HOME" location="../../.."/>
+ <property name="example" value="MenuExample" />
+
+ <property file="${ROYALE_HOME}/env.properties"/>
+ <property environment="env"/>
+ <property file="${ROYALE_HOME}/build.properties"/>
+ <property name="ROYALE_HOME" value="${ROYALE_HOME}"/>
+
+ <include file="${basedir}/../../build_example.xml" />
+
+ <target name="main" depends="clean,build_example.compile"
description="Clean build of ${example}">
+ </target>
+
+ <target name="clean">
+ <delete dir="${basedir}/bin" failonerror="false" />
+ <delete dir="${basedir}/bin-debug" failonerror="false" />
+ <delete dir="${basedir}/bin-release" failonerror="false" />
+ <delete dir="${basedir}/target" failonerror="false" />
+ </target>
+
+ <target name="examine" depends="build_example.get.browser">
+ <property name="which" value="debug" />
+ <echo message="Click button to open Menu."/>
+ <exec executable="${browser}" dir="${basedir}/bin-${which}"
failonerror="true">
+ <arg value="${basedir}/bin-${which}/${example}.html"/>
+ </exec>
+ <exec executable="${browser}" dir="${basedir}/bin/js-${which}"
failonerror="true">
+ <arg value="${basedir}/bin/js-${which}/index.html"/>
+ </exec>
+ </target>
+
+</project>
diff --git a/examples/royale/MenuExample/src/main/royale/MenuExample.mxml
b/examples/royale/MenuExample/src/main/royale/MenuExample.mxml
new file mode 100644
index 0000000..16d58f9
--- /dev/null
+++ b/examples/royale/MenuExample/src/main/royale/MenuExample.mxml
@@ -0,0 +1,36 @@
+<?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.
+//
+////////////////////////////////////////////////////////////////////////////////
+-->
+<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:local="*"
+ xmlns:models="models.*"
+ xmlns:js="library://ns.apache.org/royale/basic"
+ >
+
+ <js:valuesImpl>
+ <js:SimpleCSSValuesImpl />
+ </js:valuesImpl>
+ <!--<js:model>
+ <models:ProductsModel />
+ </js:model>-->
+ <js:initialView>
+ <local:MyInitialView />
+ </js:initialView>
+</js:Application>
diff --git a/examples/royale/MenuExample/src/main/royale/MyInitialView.mxml
b/examples/royale/MenuExample/src/main/royale/MyInitialView.mxml
new file mode 100644
index 0000000..73baa6f
--- /dev/null
+++ b/examples/royale/MenuExample/src/main/royale/MyInitialView.mxml
@@ -0,0 +1,161 @@
+<?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.
+
+-->
+<js:View xmlns:fx="http://ns.adobe.com/mxml/2009"
+ xmlns:js="library://ns.apache.org/royale/basic"
+ xmlns:local="*"
+ className="MyView">
+
+ <fx:Style>
+ @namespace js "library://ns.apache.org/royale/basic";
+
+ /**
+ * the View needs a background-color so that mouse events will
+ * be picked up in order to close the menu without making a
selection.
+ */
+ .MyView {
+ background-color: #FFFFFF;
+ }
+
+ .Output {
+ color: blue;
+ }
+
+ </fx:Style>
+
+ <fx:Script>
+ <![CDATA[
+ import org.apache.royale.collections.ArrayList;
+ import org.apache.royale.core.UIBase;
+ import org.apache.royale.events.Event;
+ import org.apache.royale.events.MouseEvent;
+ import org.apache.royale.html.Menu;
+
+ /*
+ * Show a simple menu made of an Array of Strings.
+ */
+
+ private var simpleData:Object = ["Open", "Edit",
"Save", "Save As", "Print", "Close"];
+
+
+ private function showSimpleMenu(component:UIBase):void
+ {
+ var menu:Menu = Menu.createMenu(simpleData);
+ menu.addEventListener("change",
handleSimpleSelection);
+ menu.show(component, 0, 20);
+ }
+
+ private function handleSimpleSelection(event:Event):void
+ {
+ var menu:Menu = event.currentTarget as Menu;
+ output.text = "You selected:
"+menu.selectedItem;
+ menu.hide();
+ }
+
+ /*
+ * Show a menu made of Objects
+ */
+
+ private var complexData:Object = [
+ {title:"Open", value:1},
+ {title:"Edit", value:2},
+ {title:"Save", value:3},
+ {title:"Save As", value:4},
+ {title:"Print", value:5},
+ {title:"Close", value:6}];
+
+ private function showComplexMenu(component:UIBase):void
+ {
+ var menu:Menu = Menu.createMenu(complexData);
+ menu.labelField = "title";
+ menu.addEventListener("change",
handleComplexSelection);
+ menu.show(component, 0, 20);
+ }
+
+ private function
handleComplexSelection(event:Event):void
+ {
+ var menu:Menu = event.currentTarget as Menu;
+ output.text = "You selected:
"+menu.selectedItem["title"]+" with value "+menu.selectedItem["value"];
+ menu.hide();
+ }
+
+ /*
+ * MenuBar
+ *
+ * Use type:"separator" to indicate a separator line in
the menus.
+ */
+
+ [Bindable]
+ private var menubarData:Array = [
+ {title: "File", value:"fileMenu", menu:[
+ {title:"Open", value:"open"},
+ {title:"Save", value:"save"},
+ {title:"Print", value:"print"},
+ {type:"separator"},
+ {title:"Close", value:"close"}]},
+ {title: "Edit", value:"editMenu", menu:[
+ {title:"Copy", value:"copy"},
+ {title:"Cut", value:"cut"},
+ {title:"Paste", value:"paste"}]},
+ {title: "View", value:"viewMenu", menu:[
+ {title:"Main", value:"main"},
+ {title:"Editor", value:"editor", menu:[
+ {title:"Text Editor",
value:"textEditor"},
+ {title:"UI Editor",
value:"uiEditor"},
+ {type:"separator"},
+ {title:"Settings Editor",
value:"settingsEditor", menu:[
+
{title:"Reset",value:"settingsReset"},
+ {title:"Change",
value:"settingsChange"}]}]},
+ {title:"Tools", value:"tools"}]},
+ {title: "Help", value:"helpMenu", menu:[
+ {title:"About", value:"about"},
+ {type:"separator"},
+ {title:"Website", value:"website"}]}];
+
+ private function
handleMenubarSelection(event:Event):void
+ {
+ var mbar:MenuBar = event.target as MenuBar;
+ output.text = "You selected:
"+mbar.selectedItem["title"]+" with value: "+mbar.selectedItem["value"];
+ }
+ ]]>
+ </fx:Script>
+
+ <js:beads>
+ <js:ViewDataBinding />
+ </js:beads>
+
+ <js:Panel title="Menu Demo" x="100" y="50" width="300" height="400">
+ <js:beads>
+ <js:BasicLayout />
+ </js:beads>
+ <js:MenuBar dataProvider="{menubarData}" x="0" y="0"
width="100%"
+
menuClass="org.apache.royale.html.CascadingMenu"
+ labelField="title"
change="handleMenubarSelection(event)" />
+
+ <js:Label id="output" x="50" y="80" className="Output" />
+
+ <js:TextButton text="Simple Menu"
click="showSimpleMenu(fromLabel)" x="10" y="150" />
+ <js:TextButton text="Complex Menu"
click="showComplexMenu(fromLabel)" x="200" y="150" />
+
+ <js:Label text="Menu appears below here" id="fromLabel" x="50"
y="190" className="Output" />
+ </js:Panel>
+
+
+
+</js:View>
--
To stop receiving notification emails like this one, please contact
[email protected].