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 2019/12/18 23:56:41 UTC
[royale-asjs] 02/02: more support for selection. Should fix #626
and #628
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 f9b9c7cfeaae56da01c916e3d4545a32fdab623e
Author: Alex Harui <ah...@apache.org>
AuthorDate: Wed Dec 18 15:55:06 2019 -0800
more support for selection. Should fix #626 and #628
---
.../src/main/royale/mx/controls/TextInput.as | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextInput.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextInput.as
index dd9ffce..63dec3b 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextInput.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextInput.as
@@ -1196,6 +1196,10 @@ public class TextInput extends UIComponent implements ITextInput
*/
public function get selectionBeginIndex():int
{
+ COMPILE::JS
+ {
+ _selectionBeginIndex = (element as HTMLInputElement).selectionStart;
+ }
return _selectionBeginIndex;
}
@@ -1205,6 +1209,10 @@ public class TextInput extends UIComponent implements ITextInput
public function set selectionBeginIndex(value:int):void
{
_selectionBeginIndex = value;
+ COMPILE::JS
+ {
+ (element as HTMLInputElement).selectionStart = value;
+ }
}
//----------------------------------
@@ -1241,6 +1249,10 @@ public class TextInput extends UIComponent implements ITextInput
*/
public function get selectionEndIndex():int
{
+ COMPILE::JS
+ {
+ _selectionEndIndex = (element as HTMLInputElement).selectionEnd;
+ }
return _selectionEndIndex;
}
@@ -1253,6 +1265,10 @@ public class TextInput extends UIComponent implements ITextInput
selectionChanged = true;
invalidateProperties();
+ COMPILE::JS
+ {
+ (element as HTMLInputElement).selectionEnd = value;
+ }
}
//----------------------------------
@@ -1308,7 +1324,13 @@ public class TextInput extends UIComponent implements ITextInput
COMPILE::JS
{
+ // Flash does not reset selection when setting text
+ // but browser does
+ _selectionBeginIndex = (element as HTMLInputElement).selectionStart;
+ _selectionEndIndex = (element as HTMLInputElement).selectionEnd;
(element as HTMLInputElement).value = value;
+ (element as HTMLInputElement).selectionStart = _selectionBeginIndex;
+ (element as HTMLInputElement).selectionEnd = _selectionEndIndex;
}
dispatchEvent(new Event('textChanged'));