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 2020/08/14 19:46:14 UTC

[royale-asjs] branch develop updated: jewel-uppercase: fix safari issue where cursor goes to end when writting in the middle

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 70bc45a  jewel-uppercase: fix safari issue where cursor goes to end when writting in the middle
70bc45a is described below

commit 70bc45ac3066ac05f50dc0564c80d27f1d9fde75
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Fri Aug 14 21:45:23 2020 +0200

    jewel-uppercase: fix safari issue where cursor goes to end when writting in the middle
---
 .../jewel/beads/controls/textinput/UpperCase.as      | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/UpperCase.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/UpperCase.as
index d89a1d8..8f1d722 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/UpperCase.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/UpperCase.as
@@ -21,7 +21,6 @@ package org.apache.royale.jewel.beads.controls.textinput
 	import org.apache.royale.core.IBead;
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.events.Event;
-	import org.apache.royale.events.IEventDispatcher;
 	import org.apache.royale.jewel.supportClasses.textinput.TextInputBase;
 	
 	/**
@@ -49,8 +48,6 @@ package org.apache.royale.jewel.beads.controls.textinput
 		{
 		}
 
-		protected var t:TextInputBase;
-		
 		/**
 		 *  @copy org.apache.royale.core.IBead#strand
 		 *  
@@ -61,8 +58,8 @@ package org.apache.royale.jewel.beads.controls.textinput
 		 */
 		public function set strand(value:IStrand):void
 		{
-			t = value as TextInputBase;
-			IEventDispatcher(t).addEventListener(Event.CHANGE, changeToUpperCase);
+			var t:TextInputBase = value as TextInputBase;
+			t.addEventListener(Event.CHANGE, changeToUpperCase);
 			t.text = t.text.toUpperCase();
 		}
 		
@@ -71,7 +68,20 @@ package org.apache.royale.jewel.beads.controls.textinput
 		 */
 		private function changeToUpperCase(event:Event):void
 		{
+			COMPILE::JS
+			{
+			// get cursor position
+			var t:TextInputBase = event as TextInputBase;
+			var start:Number = t.input.selectionStart;
+			var end:Number = t.input.selectionEnd;
+			
+			// chage text
 			t.text = t.text.toUpperCase();
+
+			// restore cursor position
+			t.input.setSelectionRange(start, end);;
+			}
 		}
 	}
 }
+		
\ No newline at end of file