How to validate content in TextMorph

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to validate content in TextMorph

CdAB63
What would be the best way of validating input in TextMorph (for
instance, allowing input only of numeric characters or only of small cap
letters)?

Reply | Threaded
Open this post in threaded view
|

Re: How to validate content in TextMorph

Chris Muller-3
>From a UI perspective, if the typed character is invalid (or makes an
invalid situation), then simply refuse it; put nothing into the
TextMorph, and, optionally, flash it.

On Wed, Aug 28, 2013 at 3:57 PM, Casimiro de Almeida Barreto
<[hidden email]> wrote:
> What would be the best way of validating input in TextMorph (for
> instance, allowing input only of numeric characters or only of small cap
> letters)?
>

Reply | Threaded
Open this post in threaded view
|

Re: How to validate content in TextMorph

marcel.taeumel (old)
In reply to this post by CdAB63
Just a small hint to another project: https://www.hpi.uni-potsdam.de/hirschfeld/trac/SqueakCommunityProjects/wiki/widgets

There is a widget that can convert input using a block:

UiLineEdit new
        helpText: 'Enter number here...';
        converter: [:txt | txt select: [:char | char isDigit]];
        autoConvert: true;
        openInHand.

Basically, it is implemented with a TextMorph that is converting the resulting text after each #keyStroke:. :)

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: How to validate content in TextMorph

CdAB63
On 30-08-2013 09:26, Marcel Taeumel wrote:
> UiLineEdit new
> helpText: 'Enter number here...';
> converter: [:txt | txt select: [:char | char isDigit]];
> autoConvert: true;
Thnx for the link. Helpful project.

CdAB