You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2022/07/20 04:55:30 UTC

[royale-asjs] branch develop updated: Emulation - Numeric Stepper - align text input with Flex behavior

This is an automated email from the ASF dual-hosted git repository.

yishayw 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 255be1b5cc Emulation - Numeric Stepper - align text input with Flex behavior
255be1b5cc is described below

commit 255be1b5cc6fb4688e4200d8ca6f026930544ac0
Author: Yishay Weiss <yi...@hotmail.com>
AuthorDate: Wed Jul 20 07:55:18 2022 +0300

    Emulation - Numeric Stepper - align text input with Flex behavior
---
 .../royale/mx/controls/beads/NumericStepperView.as | 23 +++++++++++-----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/NumericStepperView.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/NumericStepperView.as
index 179c17f951..4242295936 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/NumericStepperView.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/NumericStepperView.as
@@ -26,6 +26,8 @@ package mx.controls.beads
     import org.apache.royale.events.Event;
     import mx.events.FocusEvent;
     import org.apache.royale.events.IEventDispatcher;
+    import org.apache.royale.html.beads.DispatchInputFinishedBead;
+    import org.apache.royale.html.accessories.RestrictTextInputBead;
 	
     /**
      *  The NumericStepperView class overrides the Basic
@@ -53,6 +55,11 @@ package mx.controls.beads
                 input.width = 44; // should be same as SWF after we adjust defaults for spinner
                 (value as UIComponent).measuredWidth = 60;
             }
+            input.addBead(new DispatchInputFinishedBead());
+            var restrictBead:RestrictTextInputBead = new RestrictTextInputBead();
+            restrictBead.restrict = "0-9\\-\\.\\,";
+            input.addBead(restrictBead);
+            input.addEventListener(DispatchInputFinishedBead.INPUT_FINISHED, syncTextAndSpinner);
         }
 
 		public function getInput():IUIBase
@@ -66,7 +73,10 @@ package mx.controls.beads
 		 */
 		override protected function inputChangeHandler(event:Event) : void
 		{
-            var isTextInputEmpty:Boolean = input.text == "";
+		}
+
+        protected function syncTextAndSpinner(event:Event=null):void
+        {
 			var signAndNumber:Array = input.text.split("-");
 			var newValue:Number = Number(signAndNumber.length == 2 ? signAndNumber[1] : signAndNumber[0]);
 			var sign:int = signAndNumber.length == 2 ? -1 : 1;
@@ -77,17 +87,6 @@ package mx.controls.beads
 			else {
 				input.text = String(spinner.value);
 			}
-            if (isTextInputEmpty)
-            {
-                input.text = ""; // We want to allow user to type a new value regardless of above constraints
-                (_strand as IEventDispatcher).addEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
-            }
-		}
-
-        private function focusOutHandler(event:FocusEvent):void
-        {
-			input.text = "" + spinner.value;
-            (_strand as IEventDispatcher).removeEventListener(FocusEvent.FOCUS_OUT, focusOutHandler);
         }
 
 	}