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 d706ac0  also block delete and backspace.  Should fix #663
d706ac0 is described below

commit d706ac0376a3032dd63a33218f266c428de66e4e
Author: Alex Harui <[email protected]>
AuthorDate: Mon Jan 13 23:30:52 2020 -0800

    also block delete and backspace.  Should fix #663
---
 .../MXRoyale/src/main/royale/mx/controls/TextInput.as  | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

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 c6063f6..7db5101 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextInput.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextInput.as
@@ -368,9 +368,15 @@ public class TextInput extends UIComponent implements 
ITextInput
         
         COMPILE::JS {
             if (value)
+            {
                 element.removeEventListener("keypress", blockInput);
-            else
+                element.removeEventListener("keydown", blockEdit);
+            }
+            else 
+            {
                 element.addEventListener("keypress", blockInput);
+                element.addEventListener("keydown", blockEdit);
+            }
         }
                
                COMPILE::SWF {
@@ -385,6 +391,16 @@ public class TextInput extends UIComponent implements 
ITextInput
         event["returnValue"] = false;
         if (event.preventDefault) event.preventDefault();        
     }
+    
+    COMPILE::JS
+    private function blockEdit(event:Event):void
+    {
+        if (event["key"] == "Delete" || event["key"] == "Backspace")
+        {
+            event["returnValue"] = false;
+            if (event.preventDefault) event.preventDefault();   
+        }
+    }
 
     //----------------------------------
     //  tabIndex

Reply via email to