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: fix selectedItem in ComboBox
Date Mon, 27 Aug 2018 18:10:14 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 536cbf8  fix selectedItem in ComboBox
536cbf8 is described below

commit 536cbf85899ad97155526844a90570b508467735
Author: Carlos Rovira <carlosrovira@apache.org>
AuthorDate: Mon Aug 27 20:10:09 2018 +0200

    fix selectedItem in ComboBox
---
 .../src/main/royale/DropDownListPlayGround.mxml    | 16 ++---
 .../Jewel/src/main/resources/jewel-manifest.xml    |  1 -
 .../jewel/beads/controllers/ComboBoxController.as  | 40 ++++++++++--
 .../controllers/DateChooserMouseController.as      |  6 +-
 .../controllers/ItemRendererMouseController.as     |  2 +-
 .../jewel/beads/controls/combobox/IComboBoxView.as |  6 +-
 .../royale/jewel/beads/views/ComboBoxView.as       | 76 +++++++++-------------
 .../Jewel/src/main/sass/components/_combobox.sass  |  1 -
 8 files changed, 80 insertions(+), 68 deletions(-)

diff --git a/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml b/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
index 2064d66..1d174da 100644
--- a/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
+++ b/examples/royale/JewelExample/src/main/royale/DropDownListPlayGround.mxml
@@ -18,21 +18,21 @@ limitations under the License.
 
 -->
 <j:SectionContent xmlns:fx="http://ns.adobe.com/mxml/2009"
-				xmlns:j="library://ns.apache.org/royale/jewel"
-				xmlns:js="library://ns.apache.org/royale/basic"
-				xmlns:html="library://ns.apache.org/royale/html"
-				xmlns:models="models.*">
+				  xmlns:j="library://ns.apache.org/royale/jewel"
+				  xmlns:js="library://ns.apache.org/royale/basic"
+				  xmlns:html="library://ns.apache.org/royale/html"
+				  xmlns:models="models.*">
     
 	<fx:Script>
 		<![CDATA[      
             import org.apache.royale.collections.ArrayList;
 
             private function dropDownListHandler(event:Event):void {
-                dropDownListResult.text = "<strong>DropDownList selecteItem:</strong>
" + dropdownlist.selectedItem;
+                dropDownListResult.html = "<strong>DropDownList selectedItem:</strong>
" + dropdownlist.selectedItem;
             }
 
             private function comboboxSelectedItem(event:Event):void {
-                comboBoxResult.text = "<strong>ComboBox selecteItem:</strong>
" + combobox.selectedItem;
+				comboBoxResult.html = "<strong>ComboBox selectedItem:</strong> " + combobox.selectedItem;
             }
 		]]>
 	</fx:Script>
@@ -51,7 +51,7 @@ limitations under the License.
 		
 		<j:DropDownList id="dropdownlist" dataProvider="{listModel.watchmen}" change="dropDownListHandler(event)"/>
 		
-		<j:Label id="dropDownListResult" html="&lt;strong>DropDownList selecteItem:&lt;/strong>
"/>
+		<j:Label id="dropDownListResult" html="&lt;strong>DropDownList selectedItem:&lt;/strong>
"/>
 
 		<!-- <j:DropDownList change="changeHandler(event)">
 			<j:dataProvider>
@@ -65,7 +65,7 @@ limitations under the License.
 		
 		<j:ComboBox id="combobox" dataProvider="{listModel.watchmen}" change="comboboxSelectedItem(event)"/>
 
-		<j:Label id="comboBoxResult" html="&lt;strong>ComboBox selecteItem:&lt;/strong>
"/>
+		<j:Label id="comboBoxResult" html="&lt;strong>ComboBox selectedItem:&lt;/strong>
"/>
 		
 	</j:Card>
 	
diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
index 819917b..39c245b 100644
--- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
+++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml
@@ -122,7 +122,6 @@
     <component id="DataItemRendererFactoryForArrayData" class="org.apache.royale.jewel.beads.itemRenderers.DataItemRendererFactoryForArrayData"/>
     <component id="DataItemRendererFactoryForCollectionView" class="org.apache.royale.jewel.beads.itemRenderers.DataItemRendererFactoryForCollectionView"/>
     <component id="TableItemRendererFactoryForCollectionView" class="org.apache.royale.jewel.beads.itemRenderers.TableItemRendererFactoryForCollectionView"/>
-    
 
     <component id="AddListItemRendererForArrayListData" class="org.apache.royale.jewel.beads.itemRenderers.AddListItemRendererForArrayListData"
/>
     <component id="DynamicRemoveItemRendererForArrayListData" class="org.apache.royale.jewel.beads.itemRenderers.DynamicRemoveItemRendererForArrayListData"
/>
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/ComboBoxController.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/ComboBoxController.as
index fd67cb0..4330a4d 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/ComboBoxController.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/ComboBoxController.as
@@ -27,42 +27,68 @@ package org.apache.royale.jewel.beads.controllers
 	import org.apache.royale.jewel.List;
 	import org.apache.royale.jewel.beads.controls.combobox.IComboBoxView;
 	
+	/**
+	 *  The ComboBoxController class is responsible for listening to
+	 *  mouse event related to ComboBox. Events such as selecting a item
+	 *  or changing the sectedItem.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion Royale 0.9.3
+	 */
 	public class ComboBoxController implements IBeadController
 	{
+		/**
+		 *  constructor.
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 */
 		public function ComboBoxController()
 		{
 		}
 		
 		private var _strand:IStrand;
 		
-		protected var viewBead:IComboBoxView;
-		
+		/**
+		 *  @copy org.apache.royale.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.9.3
+		 */
 		public function set strand(value:IStrand):void
 		{
 			_strand = value;
 			
 			viewBead = _strand.getBeadByType(IComboBoxView) as IComboBoxView;
 			if (viewBead) {
-				finishSetup(null);
+				finishSetup();
 			} else {
 				IEventDispatcher(_strand).addEventListener("viewChanged", finishSetup);
 			}
 		}
+
+		protected var viewBead:IComboBoxView;
 		
-		protected function finishSetup(event:Event):void
+		protected function finishSetup(event:Event = null):void
 		{
 			if (viewBead == null) {
 				viewBead = _strand.getBeadByType(IComboBoxView) as IComboBoxView;
 			}
 			
-			IEventDispatcher(viewBead.popupButton).addEventListener("click", handleButtonClick);
-            IEventDispatcher(viewBead.textInputField).addEventListener("click", handleButtonClick);
+			IEventDispatcher(viewBead.button).addEventListener("click", handleButtonClick);
+            IEventDispatcher(viewBead.textinput).addEventListener("click", handleButtonClick);
 		}
 		
 		protected function handleButtonClick(event:MouseEvent):void
 		{			
 			viewBead.popUpVisible = !viewBead.popUpVisible;
-			IEventDispatcher(viewBead.popUp).addEventListener("change", handleListChange);
+			IEventDispatcher(viewBead.popup).addEventListener("change", handleListChange);
 		}
 		
 		private function handleListChange(event:Event):void
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/DateChooserMouseController.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/DateChooserMouseController.as
index 20ae861..fb146cf 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/DateChooserMouseController.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/DateChooserMouseController.as
@@ -37,7 +37,7 @@ package org.apache.royale.jewel.beads.controllers
 	 *  @langversion 3.0
 	 *  @playerversion Flash 10.2
 	 *  @playerversion AIR 2.6
-	 *  @productversion Royale 0.0
+	 *  @productversion Royale 0.9.3
 	 */
 	public class DateChooserMouseController implements IBeadController
 	{
@@ -47,7 +47,7 @@ package org.apache.royale.jewel.beads.controllers
 		 *  @langversion 3.0
 		 *  @playerversion Flash 10.2
 		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.0
+		 *  @productversion Royale 0.9.3
 		 */
 		public function DateChooserMouseController()
 		{
@@ -61,7 +61,7 @@ package org.apache.royale.jewel.beads.controllers
 		 *  @langversion 3.0
 		 *  @playerversion Flash 10.2
 		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.0
+		 *  @productversion Royale 0.9.3
 		 */
 		public function set strand(value:IStrand):void
 		{
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/ItemRendererMouseController.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/ItemRendererMouseController.as
index 5d6e986..c4e3dc0 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/ItemRendererMouseController.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/ItemRendererMouseController.as
@@ -91,7 +91,7 @@ COMPILE::JS {
 				goog.events.listen(element, goog.events.EventType.MOUSEOVER, this.handleMouseOver);
 				goog.events.listen(element, goog.events.EventType.MOUSEOUT, this.handleMouseOut);
 				goog.events.listen(element, goog.events.EventType.MOUSEDOWN, this.handleMouseDown);
-				goog.events.listen(element, goog.events.EventType.MOUSEUP, this.handleMouseUp);
+				goog.events.listen(element, goog.events.EventType.CLICK, this.handleMouseUp);
 			}
 		}
 		
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/combobox/IComboBoxView.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/combobox/IComboBoxView.as
index ec0c8ae..be90201 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/combobox/IComboBoxView.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/combobox/IComboBoxView.as
@@ -40,7 +40,7 @@ package org.apache.royale.jewel.beads.controls.combobox
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9.3
 		 */
-		function get textInputField():Object;
+		function get textinput():Object;
 		
 		/**
 		 *  The sub-component used for the button to activate the pop-up.
@@ -50,7 +50,7 @@ package org.apache.royale.jewel.beads.controls.combobox
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9.3
 		 */
-		function get popupButton():Object;
+		function get button():Object;
 		
 		/**
 		 *  The component housing the selection list.
@@ -60,7 +60,7 @@ package org.apache.royale.jewel.beads.controls.combobox
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9.3
 		 */
-		function get popUp():Object;
+		function get popup():Object;
 		
 		/**
 		 *  Determines whether or not the pop-up with the selection list is visible or not.
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
index dc2670d..d3d36f5 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
@@ -55,8 +55,7 @@ package org.apache.royale.jewel.beads.views
 			super();
 		}
 		
-		private var input:TextInput;
-		
+		private var _textinput:TextInput;
 		/**
 		 *  The TextInput component of the ComboBox.
 		 * 
@@ -67,13 +66,12 @@ package org.apache.royale.jewel.beads.views
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9.3
 		 */
-		public function get textInputField():Object
+		public function get textinput():Object
 		{
-			return input;
+			return _textinput;
 		}
 		
-		private var button:Button;
-		
+		private var _button:Button;
 		/**
 		 *  The Button component of the ComboBox.
 		 * 
@@ -84,12 +82,12 @@ package org.apache.royale.jewel.beads.views
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9.3
 		 */
-		public function get popupButton():Object
+		public function get button():Object
 		{
-			return button;
+			return _button;
 		}
 		
-		private var list:StyledUIBase;
+		private var _list:List;
 		
 		/**
 		 *  The pop-up list component of the ComboBox.
@@ -101,9 +99,9 @@ package org.apache.royale.jewel.beads.views
 		 *  @playerversion AIR 2.6
 		 *  @productversion Royale 0.9.3
 		 */
-		public function get popUp():Object
+		public function get popup():Object
 		{
-			return list;
+			return _list;
 		}
 		
 		/**
@@ -117,39 +115,26 @@ package org.apache.royale.jewel.beads.views
 			
 			var host:StyledUIBase = value as StyledUIBase;
 			
-			input = new TextInput();
-			// input.className = "ComboBoxTextInput";			
+			_textinput = new TextInput();
 			
-			button = new Button();
-			// button.style = {
-			// 	"padding": 0,
-			// 	"margin": 0
-			// };
-			button.text = '\u25BC';
+			_button = new Button();
+			_button.text = '\u25BC';
 			
 			// if (isNaN(host.width)) input.width = 100;
 			
-			// COMPILE::JS 
-			// {
-			// 	// inner components are absolutely positioned so we want to make sure the host is
the offset parent
-			// 	if (!host.element.style.position)
-			// 	{
-			// 		host.element.style.position = "relative";
-			// 	}
-			// }
-			host.addElement(input);
-			host.addElement(button);
+			host.addElement(_textinput);
+			host.addElement(_button);
 			
 			var popUpClass:Class = ValuesManager.valuesImpl.getValue(_strand, "iPopUp") as Class;
-			list = new popUpClass() as StyledUIBase;
-			list.visible = false;
+			_list = new popUpClass() as List;
+			_list.visible = false;
             // list.addClass("hidden");
 			
 			var model:IComboBoxModel = _strand.getBeadByType(IComboBoxModel) as IComboBoxModel;
 			model.addEventListener("selectedIndexChanged", handleItemChange);
 			model.addEventListener("selectedItemChanged", handleItemChange);
 			
-			IEventDispatcher(_strand).addEventListener("sizeChanged", handleSizeChange);
+			// IEventDispatcher(_strand).addEventListener("sizeChanged", handleSizeChange);
 			
 			// set initial value and positions using default sizes
 			itemChangeAction();
@@ -168,7 +153,7 @@ package org.apache.royale.jewel.beads.views
 		 */
 		public function get popUpVisible():Boolean
 		{
-			if (list) return list.visible;
+			if (_list) return _list.visible;
 			else return false;
 		}
 		/**
@@ -177,25 +162,25 @@ package org.apache.royale.jewel.beads.views
 		 */
 		public function set popUpVisible(value:Boolean):void
 		{
-			if (value && !list.visible) {
+			if (value && !_list.visible) {
 				var model:IComboBoxModel = _strand.getBeadByType(IComboBoxModel) as IComboBoxModel;
-				list.model = model;
+				_list.model = model;
 				// list.width = input.width;
 				// list.height = 200;
-                list.visible = true;
+                _list.visible = true;
                 // list.removeClass("hidden");
 				
 				var origin:Point = new Point(0, button.y+button.height);
 				var relocated:Point = PointUtils.localToGlobal(origin,_strand);
-				list.x = relocated.x
-				list.y = relocated.y;
+				_list.x = relocated.x
+				_list.y = relocated.y;
 				
 				var popupHost:IPopUpHost = UIUtils.findPopUpHost(_strand as IUIBase);
-				popupHost.popUpParent.addElement(list);
+				popupHost.popUpParent.addElement(_list);
 			}
-			else if (list.visible) {
-				UIUtils.removePopUp(list);
-                list.visible = false;
+			else if (_list.visible) {
+				UIUtils.removePopUp(_list);
+                _list.visible = false;
                 // list.addClass("hidden");
 			}
 		}
@@ -223,7 +208,10 @@ package org.apache.royale.jewel.beads.views
 		protected function itemChangeAction():void
 		{
 			var model:IComboBoxModel = _strand.getBeadByType(IComboBoxModel) as IComboBoxModel;
-			input.text = getLabelFromData(model,model.selectedItem);
+			_textinput.text = getLabelFromData(model, model.selectedItem);
+
+			// var host:StyledUIBase = StyledUIBase(_strand);
+			// host.dispatchEvent(new Event("change"));
 		}
 		
 		/**
@@ -232,7 +220,7 @@ package org.apache.royale.jewel.beads.views
 		 */
 		protected function sizeChangeAction():void
 		{
-			var host:StyledUIBase = StyledUIBase(_strand);
+			//var host:StyledUIBase = StyledUIBase(_strand);
 			
 			// input.x = 0;
 			// input.y = 0;
diff --git a/frameworks/projects/Jewel/src/main/sass/components/_combobox.sass b/frameworks/projects/Jewel/src/main/sass/components/_combobox.sass
index 7bd3a73..b8919bf 100644
--- a/frameworks/projects/Jewel/src/main/sass/components/_combobox.sass
+++ b/frameworks/projects/Jewel/src/main/sass/components/_combobox.sass
@@ -63,7 +63,6 @@ j|ComboBoxList
     IBeadView:  ClassReference("org.apache.royale.jewel.beads.views.ListView")
     IBeadController: ClassReference("org.apache.royale.jewel.beads.controllers.ListSingleSelectionMouseController")
     IBeadLayout: ClassReference("org.apache.royale.jewel.beads.layouts.VerticalLayout")
-    // IDataProviderItemRendererMapper: ClassReference("org.apache.royale.html.beads.TextItemRendererFactoryForArrayData")
     IDataProviderItemRendererMapper: ClassReference("org.apache.royale.jewel.beads.itemRenderers.DataItemRendererFactoryForCollectionView")
     IItemRendererClassFactory: ClassReference("org.apache.royale.core.ItemRendererClassFactory")
     IItemRenderer: ClassReference("org.apache.royale.jewel.itemRenderers.ListItemRenderer")


Mime
View raw message