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/06 05:56:26 UTC
[royale-asjs] branch develop updated: support 'textInput' event
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
The following commit(s) were added to refs/heads/develop by this push:
new 7ee8ecf support 'textInput' event
7ee8ecf is described below
commit 7ee8ecf2153ed846e290f0305dfbbb03d60ff239
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Dec 5 21:56:10 2019 -0800
support 'textInput' event
---
.../MXRoyale/src/main/royale/mx/controls/TextInput.as | 11 ++++++++++-
.../MXRoyale/src/main/royale/mx/events/KeyboardEvent.as | 5 +++++
.../MXRoyale/src/main/royale/mx/events/TextEvent.as | 15 +++++++++++++--
3 files changed, 28 insertions(+), 3 deletions(-)
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 4be2093..dfd4b33 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextInput.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextInput.as
@@ -31,6 +31,8 @@ import mx.core.ITextInput;
import mx.core.UIComponent;
import mx.core.UITextField;
import mx.events.FlexEvent;
+import mx.events.KeyboardEvent;
+import mx.events.TextEvent;
import org.apache.royale.core.ITextModel;
import org.apache.royale.events.Event;
@@ -1613,7 +1615,7 @@ public class TextInput extends UIComponent implements ITextInput
* @playerversion AIR 2.6
* @productversion Royale 0.0
*/
- public function textChangeHandler(event:Event):void
+ public function textChangeHandler(event:KeyboardEvent):void
{
if (!inSetter)
{
@@ -1638,6 +1640,13 @@ public class TextInput extends UIComponent implements ITextInput
event.preventDefault();
dispatchEvent(new Event(FlexEvent.ENTER));
}
+ else
+ {
+ var textEvent:TextEvent = new TextEvent(TextEvent.TEXT_INPUT, false, true);
+ textEvent.text = event['key'];
+ if (!dispatchEvent(textEvent))
+ event.preventDefault();
+ }
}
//--------------------------------------------------------------------------
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/events/KeyboardEvent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/events/KeyboardEvent.as
index 6601492..d520358 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/events/KeyboardEvent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/events/KeyboardEvent.as
@@ -68,6 +68,11 @@ public class KeyboardEvent extends flash.events.KeyboardEvent
{
}
+ public function get key():String
+ {
+ return String.fromCharCode(charCode);
+ }
+
private static function platformConstant(s:uint):uint
{
return s;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/events/TextEvent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/events/TextEvent.as
index c7a3de1..70fbdbe 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/events/TextEvent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/events/TextEvent.as
@@ -37,7 +37,7 @@ import org.apache.royale.events.IRoyaleEvent;
* @royalesuppresspublicvarwarning
*/
COMPILE::SWF
-public class TextEvent extends flash.events.TextEvent
+public class TextEvent extends org.apache.royale.events.Event
{
private static function platformConstant(s:String):String
{
@@ -48,7 +48,18 @@ public class TextEvent extends flash.events.TextEvent
public function TextEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, text:String = "")
{
- super(type, bubbles, cancelable,text);
+ super(type, bubbles, cancelable);
+ this.text = text;
+ }
+
+ private var _text:String;
+ public function get text():String
+ {
+ return _text;
+ }
+ public function set text(value:String):void
+ {
+ _text = value;
}
}