You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2018/11/07 10:29:20 UTC

[royale-asjs] branch develop updated: deselect examples with List and ComboBox (to make it work)

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 e58d968  deselect examples with List and ComboBox (to make it work)
e58d968 is described below

commit e58d9688ef02e212fdf767013c9747783766f33e
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Wed Nov 7 11:29:13 2018 +0100

    deselect examples with List and ComboBox (to make it work)
---
 .../src/main/royale/ComboBoxPlayGround.mxml        | 23 +++++++++++++++++++++-
 .../src/main/royale/DropDownListPlayGround.mxml    |  2 +-
 .../src/main/royale/ListPlayGround.mxml            | 23 +++++++++++++++++++++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml b/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
index fdd5311..bb45b22 100644
--- a/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
+++ b/examples/royale/JewelExample/src/main/royale/ComboBoxPlayGround.mxml
@@ -45,6 +45,26 @@ limitations under the License.
 			{
 				watchmenComboBox.dataProvider = new ArrayList(["blue", "red", "yellow", "green"]);
 			}
+
+			private function describeItem(item:*):String {
+				const intro:String = "<strong>DropDownList selectedItem:</strong> ";
+				var evaluated:String;
+				if (item is String) {
+					evaluated = 'String value: \'' + item + '\'';
+				} else {
+					if (item === null || item === undefined) {
+						evaluated = '[Nothing Selected]'
+					}
+					else {
+						if (item is IconListVO) {
+							evaluated = 'Object\'s label field: \'' + IconListVO(item).label + '\'';
+						} else {
+							evaluated = 'Object : ' + item;
+						}
+					}
+				}
+				return intro + evaluated;
+			}
 		]]>
 	</fx:Script>
 
@@ -178,7 +198,8 @@ limitations under the License.
 				<j:HGroup gap="3" itemsVerticalAlign="itemsCentered">
 					<j:ComboBox id="cmb2" labelField="label" dataProvider="{listModel.avengers}" selectedItem="{listModel.avengers.getItemAt(3)}" />
 				</j:HGroup>
-				<j:Label text="selectedItem: {(cmb2.selectedItem as IconListVO).label}"/>
+				<j:Label html="{describeItem(cmb2.selectedItem)}"/>
+				<j:Button text="Deselect" click="cmb2.selectedIndex = -1"/>
 			</j:Card>
 		</j:GridCell>
 	</j:Grid>
diff --git a/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml b/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
index 0996313..0558abb 100644
--- a/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
+++ b/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
@@ -28,7 +28,7 @@ limitations under the License.
 		import vos.IconListVO;
 
 
-		private function describeItem(item:Object):String {
+		private function describeItem(item:*):String {
 			const intro:String = "<strong>DropDownList selectedItem:</strong> ";
 			var evaluated:String;
 			if (item is String) {
diff --git a/examples/royale/JewelExample/src/main/royale/ListPlayGround.mxml b/examples/royale/JewelExample/src/main/royale/ListPlayGround.mxml
index eea0870..c00692e 100644
--- a/examples/royale/JewelExample/src/main/royale/ListPlayGround.mxml
+++ b/examples/royale/JewelExample/src/main/royale/ListPlayGround.mxml
@@ -89,6 +89,26 @@ limitations under the License.
 				(iconList.dataProvider as ArrayList).removeAll();
 				// listModel.iconListData.removeAll();
 			}
+
+			private function describeItem(item:*):String {
+				const intro:String = "<strong>DropDownList selectedItem:</strong> ";
+				var evaluated:String;
+				if (item is String) {
+					evaluated = 'String value: \'' + item + '\'';
+				} else {
+					if (item === null || item === undefined) {
+						evaluated = '[Nothing Selected]'
+					}
+					else {
+						if (item is IconListVO) {
+							evaluated = 'Object\'s label field: \'' + IconListVO(item).label + '\'';
+						} else {
+							evaluated = 'Object : ' + item;
+						}
+					}
+				}
+				return intro + evaluated;
+			}
 		]]>
 	</fx:Script>
 
@@ -107,7 +127,7 @@ limitations under the License.
 			<j:Card>
 				<html:H3 text="Jewel List"/>
 				<j:List id="list" width="200" height="300" dataProvider="{simple}" change="onChange(event)"/>
-				<j:Label id="selected"/>
+				<j:Label id="selected" html="{describeItem(list.selectedItem)}"/>
 				<j:HGroup gap="3" itemsVerticalAlign="itemsCentered">
 					<j:Label text="Select list by index: "/>
 					<j:NumericStepper valueChange="list.selectedIndex = event.target.value" minimum="0" maximum="11"/>
@@ -117,6 +137,7 @@ limitations under the License.
 					<j:NumericStepper valueChange="list.selectedItem = list.dataProvider.getItemAt(event.target.value)" minimum="0" maximum="11"/>
 				</j:HGroup>
 				<j:Button text="Assign new data" click="assignNewData()"/>
+				<j:Button text="Deselect" click="list.selectedIndex = -1"/>
 			</j:Card>
 		</j:GridCell>