You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/09/21 18:09:29 UTC

[royale-asjs] 01/02: get verticalScrollPosition working for TextArea

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

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 4ef95ab253271e672efa510fc251eca6f04c5448
Author: Alex Harui <ah...@apache.org>
AuthorDate: Fri Sep 21 11:08:52 2018 -0700

    get verticalScrollPosition working for TextArea
---
 .../MXRoyale/src/main/royale/mx/controls/TextArea.as     |  4 ++++
 .../src/main/royale/mx/core/ScrollControlBase.as         | 16 ++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextArea.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextArea.as
index 8a8296b..6495bc8 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextArea.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextArea.as
@@ -23,6 +23,7 @@ COMPILE::JS {
 	import goog.events;
 	import org.apache.royale.core.WrappedHTMLElement;
 	import org.apache.royale.html.util.addElementToWrapper;
+    import org.apache.royale.utils.CSSUtils;
 }
 COMPILE::SWF
 {
@@ -1750,6 +1751,9 @@ public class TextArea extends ScrollControlBase
 		COMPILE::JS
 		{
 			(element as HTMLTextAreaElement).value = value;
+            verticalScrollSize = CSSUtils.toNumber(getComputedStyle(element).lineHeight.toString(), width);
+            if (verticalScrollPosition)
+                element.scrollTop = verticalScrollPosition * verticalScrollSize;
 			dispatchEvent(new Event('textChange'));
 		}
 //        textSet = true;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/ScrollControlBase.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/ScrollControlBase.as
index 4c5901a..3c795ae 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/ScrollControlBase.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/ScrollControlBase.as
@@ -387,6 +387,10 @@ public class ScrollControlBase extends UIComponent
 //        if (horizontalScrollBar)
 //            horizontalScrollBar.scrollPosition = value;
 
+        COMPILE::JS
+        {
+            element.scrollLeft = value;
+        }
         dispatchEvent(new Event("viewChanged"));
     }
 
@@ -690,6 +694,14 @@ public class ScrollControlBase extends UIComponent
      */
     mx_internal var _verticalScrollPosition:Number = 0;
 
+    /**
+     *  @private
+     *  Storage for the verticalScrollSize property.
+     *  Flex scrolls by step sizes other than pixels.  TextArea
+     *  scrolls by lines of text, Lists scroll by itemRendererIndex
+     */
+    protected var verticalScrollSize:Number = 1;
+    
     [Bindable("scroll")]
     [Bindable("viewChanged")]
     [Inspectable(defaultValue="0")]
@@ -722,6 +734,10 @@ public class ScrollControlBase extends UIComponent
 //        if (verticalScrollBar)
 //            verticalScrollBar.scrollPosition = value;
 
+        COMPILE::JS
+        {
+            element.scrollTop = value * verticalScrollSize;
+        }
         dispatchEvent(new Event("viewChanged"));
     }