royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject [royale-asjs] branch develop updated: add labelField to CombBox and improve examples
Date Tue, 28 Aug 2018 09:59:51 GMT
This is an automated email from the ASF dual-hosted git repository.

carlosrovira 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 349522b  add labelField to CombBox and improve examples
349522b is described below

commit 349522b61d13aa64f75f06c61350bf2346ef24ae
Author: Carlos Rovira <carlosrovira@apache.org>
AuthorDate: Tue Aug 28 11:59:46 2018 +0200

    add labelField to CombBox and improve examples
---
 .../src/main/royale/DropDownListPlayGround.mxml    | 62 ++++++++++++----
 .../src/main/royale/models/ListsModel.as           | 17 +++++
 .../royale/org/apache/royale/jewel/ComboBox.as     | 82 +++++++++++++++++-----
 3 files changed, 132 insertions(+), 29 deletions(-)

diff --git a/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml b/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
index e943b62..e57c3e2 100644
--- a/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
+++ b/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
@@ -27,12 +27,20 @@ limitations under the License.
 		<![CDATA[      
             import org.apache.royale.collections.ArrayList;
 
-            private function dropDownListHandler(event:Event):void {
-                dropDownListResult.html = "<strong>DropDownList selectedItem:</strong>
" + dropdownlist.selectedItem;
+            private function watchmenDropDownListHandler(event:Event):void {
+                watchmenDropDownListResult.html = "<strong>DropDownList selectedItem:</strong>
" + event.target.selectedItem;
             }
 
-            private function comboboxSelectedItem(event:Event):void {
-				comboBoxResult.html = "<strong>ComboBox selectedItem:</strong> " + combobox.selectedItem;
+            private function watchmenComboBoxSelectedItem(event:Event):void {
+				watchmenComboBoxResult.html = "<strong>ComboBox selectedItem:</strong> "
+ event.target.selectedItem;
+            }
+            
+			private function avengerswatchmenDropDownListHandler(event:Event):void {
+                avengersDropDownListResult.html = "<strong>DropDownList selectedItem:</strong>
" + event.target.selectedItem.nickname;
+            }
+
+            private function avengerswatchmenComboBoxSelectedItem(event:Event):void {
+				avengersComboBoxResult.html = "<strong>ComboBox selectedItem:</strong> "
+ event.target.selectedItem.nickname;
             }
 		]]>
 	</fx:Script>
@@ -54,15 +62,43 @@ limitations under the License.
 				<html:H3 text="Jewel DropDownList"/>
 				
 				<j:HGroup gap="3" itemsVerticalAlign="itemsCentered">
-					<j:DropDownList id="dropdownlist" dataProvider="{listModel.watchmen}" change="dropDownListHandler(event)"/>
-					<j:Label id="dropDownListResult" html="&lt;strong>DropDownList selectedItem:&lt;/strong>
"/>
+					<j:DropDownList dataProvider="{listModel.watchmen}" change="watchmenDropDownListHandler(event)"/>
+					<j:Label id="watchmenDropDownListResult" html="&lt;strong>DropDownList selectedItem:&lt;/strong>
"/>
+				</j:HGroup>
+			</j:Card>
+
+		</j:GridCell>
+
+		<j:GridCell desktopNumerator="1" desktopDenominator="2"
+					tabletNumerator="1" tabletDenominator="2"
+					phoneNumerator="1" phoneDenominator="1">
+
+			<j:Card>
+				
+				<html:H3 text="Jewel ComboBox"/>
+				
+				<j:HGroup gap="3" itemsVerticalAlign="itemsCentered">
+					<j:ComboBox dataProvider="{listModel.watchmen}" change="watchmenComboBoxSelectedItem(event)"/>
+					<j:Label id="watchmenComboBoxResult" html="&lt;strong>ComboBox selectedItem:&lt;/strong>
"/>
+				</j:HGroup>
+				
+			</j:Card>
+		</j:GridCell>
+	</j:Grid>
+	
+	<j:Grid gap="true" itemsVerticalAlign="itemsSameHeight">
+		<j:GridCell desktopNumerator="1" desktopDenominator="2"
+					tabletNumerator="1" tabletDenominator="2"
+					phoneNumerator="1" phoneDenominator="1">
+			<j:Card>
+				
+				<html:H3 text="Jewel DropDownList"/>
+				
+				<j:HGroup gap="3" itemsVerticalAlign="itemsCentered">
+					<j:DropDownList labelField="nickname" dataProvider="{listModel.avengers}" change="avengerswatchmenDropDownListHandler(event)"/>
+					<j:Label id="avengersDropDownListResult" html="&lt;strong>DropDownList selectedItem:&lt;/strong>
"/>
 				</j:HGroup>
 
-				<!-- <j:DropDownList change="changeHandler(event)">
-					<j:dataProvider>
-						<j:ArrayList id="avengersCharacters" source="[Iron Man, Hulk, Thor, Captain America,
Black Widow]" />
-					</j:dataProvider>
-				</j:DropDownList> -->
 			</j:Card>
 
 		</j:GridCell>
@@ -76,8 +112,8 @@ limitations under the License.
 				<html:H3 text="Jewel ComboBox"/>
 				
 				<j:HGroup gap="3" itemsVerticalAlign="itemsCentered">
-					<j:ComboBox id="combobox" dataProvider="{listModel.watchmen}" change="comboboxSelectedItem(event)"/>
-					<j:Label id="comboBoxResult" html="&lt;strong>ComboBox selectedItem:&lt;/strong>
"/>
+					<j:ComboBox labelField="nickname" dataProvider="{listModel.avengers}" change="avengerswatchmenComboBoxSelectedItem(event)"/>
+					<j:Label id="avengersComboBoxResult" html="&lt;strong>ComboBox selectedItem:&lt;/strong>
"/>
 				</j:HGroup>
 				
 			</j:Card>
diff --git a/examples/royale/JewelExample/src/main/royale/models/ListsModel.as b/examples/royale/JewelExample/src/main/royale/models/ListsModel.as
index 9f3e468..880951f 100644
--- a/examples/royale/JewelExample/src/main/royale/models/ListsModel.as
+++ b/examples/royale/JewelExample/src/main/royale/models/ListsModel.as
@@ -41,6 +41,23 @@ package models
 			return _watchmen;
 		}
 
+		private var _avengers:ArrayList = new ArrayList([
+			{nickname: "Iron Man"},
+			{nickname: "Hulk"}, 
+			{nickname: "Thor"},
+			{nickname: "Captain America"},
+            {nickname: "Black Widow"},
+            {nickname: "Hawkeye"},
+            {nickname: "Vision"},
+            {nickname: "Scarlet Witch"},
+            {nickname: "Spiderman"}
+		]);
+		public function get avengers():ArrayList
+		{
+			return _avengers;
+		}
+		
+
 		
 		/**
 		 * Used in the List example.
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
index 93988f6..e329e29 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/ComboBox.as
@@ -18,11 +18,12 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.jewel
 {
-    import org.apache.royale.core.IUIBase;
 	import org.apache.royale.core.StyledUIBase;
-
     import org.apache.royale.core.IComboBoxModel;
-    import org.apache.royale.jewel.beads.models.ComboBoxModel;
+	import org.apache.royale.core.ISelectionModel;
+	import org.apache.royale.core.IDataProviderModel;
+	import org.apache.royale.core.IListPresentationModel;
+	import org.apache.royale.jewel.beads.models.ListPresentationModel;
 	
 	[Event(name="change", type="org.apache.royale.events.Event")]
 	
@@ -40,7 +41,7 @@ package org.apache.royale.jewel
 	 *  @langversion 3.0
 	 *  @playerversion Flash 10.2
 	 *  @playerversion AIR 2.6
-	 *  @productversion Royale 0.0
+	 *  @productversion Royale 0.9.3
 	 */
 	public class ComboBox extends StyledUIBase
 	{
@@ -50,7 +51,7 @@ package org.apache.royale.jewel
 		 *  @langversion 3.0
 		 *  @playerversion Flash 10.2
 		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.0
+		 *  @productversion Royale 0.9.3
 		 */
 		public function ComboBox()
 		{
@@ -65,15 +66,41 @@ package org.apache.royale.jewel
 		 *  @langversion 3.0
 		 *  @playerversion Flash 10.2
 		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.0
+		 *  @productversion Royale 0.9.3
+		 *  @royaleignorecoercion org.apache.royale.core.IDataProviderModel
 		 */
 		public function get dataProvider():Object
 		{
-			return IComboBoxModel(model).dataProvider;
+			return IDataProviderModel(model).dataProvider;
 		}
+		/**
+		 * @royaleignorecoercion org.apache.royale.core.IDataProviderModel
+		 */
 		public function set dataProvider(value:Object):void
 		{
-			IComboBoxModel(model).dataProvider = value;
+			IDataProviderModel(model).dataProvider = value;
+		}
+
+		/**
+		 *  The name of field within the data used for display. Each item of the
+		 *  data should have a property with this name.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 *  @royaleignorecoercion org.apache.royale.core.IDataProviderModel
+		 */
+		public function get labelField():String
+		{
+			return IDataProviderModel(model).labelField;
+		}
+		/**
+		 * @royaleignorecoercion org.apache.royale.core.IDataProviderModel
+		 */
+		public function set labelField(value:String):void
+		{
+            IDataProviderModel(model).labelField = value;
 		}
 		
         [Bindable("change")]
@@ -84,35 +111,58 @@ package org.apache.royale.jewel
 		 *  @langversion 3.0
 		 *  @playerversion Flash 10.2
 		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.0
+		 *  @productversion Royale 0.9.3
+		 *  @royaleignorecoercion org.apache.royale.core.ISelectionModel
 		 */
 		public function get selectedIndex():int
 		{
-			return IComboBoxModel(model).selectedIndex;
+			return ISelectionModel(model).selectedIndex;
 		}
+		/**
+		 * @royaleignorecoercion org.apache.royale.core.ISelectionModel
+		 */
 		public function set selectedIndex(value:int):void
 		{
-			IComboBoxModel(model).selectedIndex = value;
+			ISelectionModel(model).selectedIndex = value;
 		}
 		
         [Bindable("change")]
 		/**
-		 *  The item that is currently selected. Changing this item changes
-		 *  the selectedIndex.
+		 *  The item currently selected. Changing this value also
+		 *  changes the selectedIndex property.
 		 *
 		 *  @langversion 3.0
 		 *  @playerversion Flash 10.2
 		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.0
+		 *  @productversion Royale 0.9.3
+		 *  @royaleignorecoercion org.apache.royale.core.ISelectionModel
 		 */
 		public function get selectedItem():Object
 		{
-			return IComboBoxModel(model).selectedItem;
+			return ISelectionModel(model).selectedItem;
 		}
 		public function set selectedItem(value:Object):void
 		{
-			IComboBoxModel(model).selectedItem = value;
+			ISelectionModel(model).selectedItem = value;
 		}
 		
+		/**
+		 *  The presentation model for the list.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 *  @royaleignorecoercion org.apache.royale.core.IListPresentationModel
+		 */
+		public function get presentationModel():IListPresentationModel
+		{
+			var presModel:IListPresentationModel = getBeadByType(IListPresentationModel) as IListPresentationModel;
+			if (presModel == null) {
+				presModel = new ListPresentationModel();
+				addBead(presModel);
+			}
+			return presModel;
+		}
 	}
 }


Mime
View raw message