flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [2/2] git commit: [flex-asjs] [refs/heads/release0.8.0] - fix event types for valuechange. Otherwise Binding would break. Events are global and should be compatible for any given event type
Date Tue, 06 Jun 2017 18:57:58 GMT
fix event types for valuechange.  Otherwise Binding would break.  Events are global and should
be compatible for any given event type


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/4df71784
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/4df71784
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/4df71784

Branch: refs/heads/release0.8.0
Commit: 4df717847eaeb12d6b14af833853852eb3cc13ce
Parents: b17c2bd
Author: Alex Harui <aharui@apache.org>
Authored: Tue Jun 6 11:58:03 2017 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Jun 6 11:58:03 2017 -0700

----------------------------------------------------------------------
 .../flex/html/beads/NumericStepperView.as       |  5 ++--
 .../beads/controllers/SliderMouseController.as  | 27 +++++++++++++++-----
 .../beads/controllers/SpinnerMouseController.as |  9 +++++--
 .../apache/flex/html/beads/models/RangeModel.as |  4 ++-
 .../html/beads/models/RangeModelExtended.as     |  9 +++++--
 .../html/beads/models/ValueToggleButtonModel.as |  5 +++-
 6 files changed, 44 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4df71784/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/NumericStepperView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/NumericStepperView.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/NumericStepperView.as
index 15e2321..5ad42dc 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/NumericStepperView.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/NumericStepperView.as
@@ -29,6 +29,7 @@ package org.apache.flex.html.beads
     import org.apache.flex.core.IUIBase;
     import org.apache.flex.core.UIBase;
 	import org.apache.flex.events.Event;
+	import org.apache.flex.events.ValueChangeEvent
 	import org.apache.flex.events.IEventDispatcher;
     import org.apache.flex.html.Label;
 	import org.apache.flex.html.Spinner;
@@ -143,11 +144,11 @@ package org.apache.flex.html.beads
 		/**
 		 * @private
 		 */
-		private function spinnerValueChanged(event:Event) : void
+		private function spinnerValueChanged(event:ValueChangeEvent) : void
 		{
 			input.text = String(spinner.value);
 			
-			var newEvent:Event = new Event(event.type,event.bubbles);
+			var newEvent:ValueChangeEvent = new ValueChangeEvent(event.type, false, false, event.oldValue,
event.newValue);
 			IEventDispatcher(_strand).dispatchEvent(newEvent);
 		}
 		

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4df71784/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SliderMouseController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SliderMouseController.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SliderMouseController.as
index 91589b5..9663aff 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SliderMouseController.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SliderMouseController.as
@@ -26,6 +26,7 @@ package org.apache.flex.html.beads.controllers
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.events.MouseEvent;
+	import org.apache.flex.events.ValueChangeEvent;
 	import org.apache.flex.geom.Point;
 	import org.apache.flex.html.beads.ISliderView;
 	import org.apache.flex.html.beads.SliderTrackView;
@@ -68,7 +69,9 @@ package org.apache.flex.html.beads.controllers
 		private var rangeModel:IRangeModel;
 		
 		private var _strand:IStrand;
-		
+
+		private var oldValue:Number;
+				
 		/**
 		 *  @copy org.apache.flex.core.IBead#strand
 		 *  
@@ -126,6 +129,7 @@ package org.apache.flex.html.beads.controllers
 			
 			origin = new Point(event.screenX, event.screenY);
 			thumb = new Point(sliderView.thumb.x,sliderView.thumb.y);
+			oldValue = rangeModel.value;
 		}
 		
 		/**
@@ -137,7 +141,8 @@ package org.apache.flex.html.beads.controllers
 			UIBase(_strand).topMostEventDispatcher.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMoveHandler);
 			UIBase(_strand).topMostEventDispatcher.removeEventListener(MouseEvent.MOUSE_UP, thumbUpHandler);
 			
-			IEventDispatcher(_strand).dispatchEvent(new Event("valueChange"));
+			var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false, oldValue,
rangeModel.value);
+			IEventDispatcher(_strand).dispatchEvent(vce);
 		}
 		
         COMPILE::SWF
@@ -160,9 +165,10 @@ package org.apache.flex.html.beads.controllers
 			var p:Number = newX/sliderView.track.width;
 			var n:Number = p*(rangeModel.maximum - rangeModel.minimum) + rangeModel.minimum;
 		
+			var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false, rangeModel.value,
n);
 			rangeModel.value = n;
 			
-			IEventDispatcher(_strand).dispatchEvent(new Event("valueChange"));
+			IEventDispatcher(_strand).dispatchEvent(vce);
 		}
 		
 		/**
@@ -179,9 +185,10 @@ package org.apache.flex.html.beads.controllers
 			var p:Number = xloc/sliderView.track.width;
 			var n:Number = p*(rangeModel.maximum - rangeModel.minimum) + rangeModel.minimum;
 			
+			var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false, rangeModel.value,
n);
 			rangeModel.value = n;
 			
-			IEventDispatcher(_strand).dispatchEvent(new Event("valueChange"));
+			IEventDispatcher(_strand).dispatchEvent(vce);
 		}
         
         /**
@@ -195,6 +202,7 @@ package org.apache.flex.html.beads.controllers
             var n:Number = p * (host.maximum - host.minimum) +
                 host.minimum;
             
+			var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false, host.value,
n);
             host.value = n;
             
             origin = parseInt(thumb.element.style.left, 10);
@@ -202,7 +210,7 @@ package org.apache.flex.html.beads.controllers
             
             calcValFromMousePosition(event, true);
             
-            host.dispatchEvent(new org.apache.flex.events.Event('valueChange'));
+            host.dispatchEvent(vce);
         }
         
         
@@ -219,6 +227,7 @@ package org.apache.flex.html.beads.controllers
             
             origin = event.clientX;
             position = parseInt(thumb.element.style.left, 10);
+            oldValue = rangeModel.value;
         }
         
         COMPILE::JS
@@ -238,8 +247,9 @@ package org.apache.flex.html.beads.controllers
                 handleThumbMove, false, this);
             
             calcValFromMousePosition(event, false);
+            var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false,
oldValue, rangeModel.value);
             
-            host.dispatchEvent(new org.apache.flex.events.Event('valueChange'));
+            host.dispatchEvent(vce);
         }
         
         
@@ -249,9 +259,12 @@ package org.apache.flex.html.beads.controllers
         private function handleThumbMove(event:BrowserEvent):void
         {
             var host:Slider = _strand as Slider;
+            var lastValue:Number = rangeModel.value;
             calcValFromMousePosition(event, false);
             
-            host.dispatchEvent(new org.apache.flex.events.Event('valueChange'));
+            var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false,
lastValue, rangeModel.value);
+            
+            host.dispatchEvent(vce);
         }
         
         

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4df71784/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SpinnerMouseController.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SpinnerMouseController.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SpinnerMouseController.as
index 2a898d8..b228980 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SpinnerMouseController.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/controllers/SpinnerMouseController.as
@@ -25,6 +25,7 @@ package org.apache.flex.html.beads.controllers
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
 	import org.apache.flex.events.MouseEvent;
+	import org.apache.flex.events.ValueChangeEvent;
 	import org.apache.flex.html.TextButton;
 	import org.apache.flex.html.beads.ISpinnerView;
     COMPILE::JS
@@ -108,8 +109,10 @@ package org.apache.flex.html.beads.controllers
 		 */
 		private function decrementClickHandler( event:org.apache.flex.events.MouseEvent ) : void
 		{
+			var oldValue:Number = rangeModel.value;
 			rangeModel.value = Math.max(rangeModel.minimum, rangeModel.value - rangeModel.stepSize);
-			IEventDispatcher(_strand).dispatchEvent(new Event("valueChange"));
+			var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false, oldValue,
rangeModel.value);
+			IEventDispatcher(_strand).dispatchEvent(vce);
 		}
 
 		/**
@@ -117,8 +120,10 @@ package org.apache.flex.html.beads.controllers
 		 */
 		private function incrementClickHandler( event:org.apache.flex.events.MouseEvent ) : void
 		{
+			var oldValue:Number = rangeModel.value;
 			rangeModel.value = Math.min(rangeModel.maximum, rangeModel.value + rangeModel.stepSize);
-			IEventDispatcher(_strand).dispatchEvent(new Event("valueChange"));
+			var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false, oldValue,
rangeModel.value);
+			IEventDispatcher(_strand).dispatchEvent(vce);
 		}
 	}
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4df71784/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModel.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModel.as
index c06d3fe..ab86d03 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModel.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModel.as
@@ -23,6 +23,7 @@ package org.apache.flex.html.beads.models
 	import org.apache.flex.core.IRangeModel;
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.EventDispatcher;
+	import org.apache.flex.events.ValueChangeEvent;
 			
 	/**
 	 *  The RangeModel class bead defines a set of for a numeric range of values
@@ -194,8 +195,9 @@ package org.apache.flex.html.beads.models
 				// what is coming in.
 				newValue = Math.max(minimum, newValue);
 				newValue = Math.min(maximum, newValue);
+				var oldValue:Number = _value;
 				_value = snap(newValue);
-				dispatchEvent(new Event("valueChange"));
+				dispatchEvent(new ValueChangeEvent("valueChange", false, false, oldValue, _value));
 			}
 		}
 		

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4df71784/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModelExtended.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModelExtended.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModelExtended.as
index ebbc4f3..fad333e 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModelExtended.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/RangeModelExtended.as
@@ -19,6 +19,7 @@
 package org.apache.flex.html.beads.models
 {
 	import org.apache.flex.events.Event;
+	import org.apache.flex.events.ValueChangeEvent;
 	import org.apache.flex.html.beads.models.RangeModel;
 
 	/**
@@ -56,8 +57,12 @@ package org.apache.flex.html.beads.models
 		}
 		override public function set value(newValue:Number):void
 		{
-			_value = newValue;
-			dispatchEvent(new Event("valueChange"));
+			if (_value != newValue)
+			{
+				var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false, _value,
newValue);
+				_value = newValue;
+				dispatchEvent(vce);
+			}
 		}
 
 		private var _labelFunction:Function;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/4df71784/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/ValueToggleButtonModel.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/ValueToggleButtonModel.as
b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/ValueToggleButtonModel.as
index 27b0a95..e8fbc76 100644
--- a/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/ValueToggleButtonModel.as
+++ b/frameworks/projects/Basic/src/main/flex/org/apache/flex/html/beads/models/ValueToggleButtonModel.as
@@ -21,6 +21,8 @@ package org.apache.flex.html.beads.models
 	
 	import org.apache.flex.core.IValueToggleButtonModel;
 	import org.apache.flex.events.Event;
+	import org.apache.flex.events.ValueChangeEvent;
+	
 
 	/**
 	 *  The ValueToggleButtonModel class bead extends the 
@@ -67,8 +69,9 @@ package org.apache.flex.html.beads.models
 		{
 			if( newValue != _value )
 			{
+				var vce:ValueChangeEvent = new ValueChangeEvent("valueChange", false, false, _value,
newValue);
 				_value = newValue;
-				dispatchEvent(new Event("valueChange"));
+				dispatchEvent(vce);
 			}
 		}
 		


Mime
View raw message