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 2019/03/06 14:41:56 UTC
[royale-asjs] branch develop updated: trying to solve input
maxlength on android devices
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 d0e3b93 trying to solve input maxlength on android devices
d0e3b93 is described below
commit d0e3b93f5b98e2d06cf12cfbcb6e5bbd6190ac24
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Wed Mar 6 15:41:49 2019 +0100
trying to solve input maxlength on android devices
---
.../jewel/beads/controls/textinput/Restrict.as | 3 ---
.../royale/jewel/beads/validators/StringValidator.as | 20 +++++++++++++++++++-
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/Restrict.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/Restrict.as
index e1662dc..247a838 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/Restrict.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/Restrict.as
@@ -31,10 +31,7 @@ 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;
- import org.apache.royale.core.UIBase;
/**
* The Restrict bead class is a specialty bead that can be used with
diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/StringValidator.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/StringValidator.as
index 4cb3ef6..d36fe0e 100644
--- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/StringValidator.as
+++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/validators/StringValidator.as
@@ -18,6 +18,10 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.royale.jewel.beads.validators
{
+ COMPILE::JS
+ {
+ import goog.events.BrowserEvent;
+ }
import org.apache.royale.core.IBead;
import org.apache.royale.core.IStrand;
import org.apache.royale.events.Event;
@@ -106,10 +110,21 @@ package org.apache.royale.jewel.beads.validators
_maxLength = value;
COMPILE::JS
{
- updateHost();
+ updateHost();
}
}
+ COMPILE::JS
+ /**
+ * solves Android issue where you can enter more characters than maxlenght in the input
+ */
+ private function forceMaxLength(event:BrowserEvent):void {
+ var input:HTMLInputElement = hostComponent.element as HTMLInputElement;
+ if(input.value.length > _maxLength) {
+ input.value = input.value.substring(0, _maxLength);
+ }
+ }
+
/**
* Override of the base class validate() method to validate a String.
*
@@ -145,9 +160,12 @@ package org.apache.royale.jewel.beads.validators
if(_maxLength > 0)
{
hostComponent.element.setAttribute('maxlength', _maxLength);
+ //solves Android issue where you can enter more characters than maxlenght in the input
+ hostComponent.element.addEventListener("keyup", forceMaxLength, false);
} else
{
hostComponent.element.removeAttribute('maxlength');
+ hostComponent.element.addEventListener("keyup", forceMaxLength, false);
}
}
}