From commits-return-6629-archive-asf-public=cust-asf.ponee.io@royale.apache.org Tue Oct 30 00:43:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id BCCDA180627 for ; Tue, 30 Oct 2018 00:43:04 +0100 (CET) Received: (qmail 47008 invoked by uid 500); 29 Oct 2018 23:43:03 -0000 Mailing-List: contact commits-help@royale.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@royale.apache.org Delivered-To: mailing list commits@royale.apache.org Received: (qmail 46999 invoked by uid 99); 29 Oct 2018 23:43:03 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Oct 2018 23:43:03 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 21AD682934; Mon, 29 Oct 2018 23:43:03 +0000 (UTC) Date: Mon, 29 Oct 2018 23:43:03 +0000 To: "commits@royale.apache.org" Subject: [royale-asjs] branch develop updated: Jewel Restrict bead and examples MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154085658304.32498.8389281289571307923@gitbox.apache.org> From: carlosrovira@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: royale-asjs X-Git-Refname: refs/heads/develop X-Git-Reftype: branch X-Git-Oldrev: eb8672ff50b02d8cc418fcb6a8eb552109857b89 X-Git-Newrev: c4bc1e226f91e016881d5609e288d4f182705dc1 X-Git-Rev: c4bc1e226f91e016881d5609e288d4f182705dc1 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 c4bc1e2 Jewel Restrict bead and examples c4bc1e2 is described below commit c4bc1e226f91e016881d5609e288d4f182705dc1 Author: Carlos Rovira AuthorDate: Tue Oct 30 00:42:55 2018 +0100 Jewel Restrict bead and examples --- .../src/main/royale/TextInputPlayGround.mxml | 12 ++ .../Jewel/src/main/resources/jewel-manifest.xml | 1 + .../jewel/beads/controls/textinput/Restrict.as | 136 +++++++++++++++++++++ 3 files changed, 149 insertions(+) diff --git a/examples/royale/JewelExample/src/main/royale/TextInputPlayGround.mxml b/examples/royale/JewelExample/src/main/royale/TextInputPlayGround.mxml index 2038f24..6d46f90 100644 --- a/examples/royale/JewelExample/src/main/royale/TextInputPlayGround.mxml +++ b/examples/royale/JewelExample/src/main/royale/TextInputPlayGround.mxml @@ -107,6 +107,18 @@ limitations under the License. + + + + + + + + + + + + diff --git a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml index 7546e45..d2189c5 100644 --- a/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml +++ b/frameworks/projects/Jewel/src/main/resources/jewel-manifest.xml @@ -122,6 +122,7 @@ + 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 new file mode 100644 index 0000000..160e6f4 --- /dev/null +++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/Restrict.as @@ -0,0 +1,136 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.jewel.beads.controls.textinput +{ + COMPILE::JS + { + import goog.events.BrowserEvent; + } + COMPILE::SWF + { + import flash.events.TextEvent; + + import org.apache.royale.core.CSSTextField; + import org.apache.royale.html.beads.ITextFieldView; + } + 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 + * any Jewel TextInputBase control. The bead uses a reg exp pattern to validate + * input from user. A text property allows to configure error text. + * + * use examples: + * Numeric pattern = -?[0-9]*(\.[0-9]+)? + * error text = "Input is not a number!" + * + * Letters and spaces only pattern = [A-Z,a-z, ]* + * error text = "Letters and spaces only"; + * + * Digits only = [0-9]* + * error text = "Digits only"; + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.4 + */ + public class Restrict implements IBead + { + /** + * constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.4 + */ + public function Restrict() + { + } + + private var _pattern:String; + + /** + * The string to use as numeric pattern. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.4 + */ + public function get pattern():String + { + return _pattern; + } + public function set pattern(value:String):void + { + _pattern = value; + // updateRestriction(); + } + + private var host:TextInputBase; + + // private function updateRestriction():void + // { + // COMPILE::JS + // { + // if (host) + // { + // host.input.setAttribute('pattern', pattern); + // } + // } + // } + + /** + * @copy org.apache.royale.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.4 + * @royaleignorecoercion org.apache.royale.core.UIBase + */ + public function set strand(value:IStrand):void + { + host = value as TextInputBase; + COMPILE::JS + { + host.input.addEventListener('input', keyEventHandler); + } + // updateRestriction(); + } + + /** + * @private + */ + COMPILE::JS + protected function keyEventHandler(event:KeyboardEvent):void + { + //event.stopImmediatePropagation(); + var re:RegExp = new RegExp(pattern, 'g'); + host.input.value = host.input.value.replace(re, ''); + } + } +}