realbasic-nug
[Top] [All Lists]

Re: Easy way to permit numbers exclusively?

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Easy way to permit numbers exclusively?
From: Thomas Reed <thomasareed at earthlink dot net>
Date: Wed, 30 Jan 2002 15:37:39 -0600
>I think something like this is bad because you block all keys like:
>- backspace (code 8)
>- enter (code 3)
>- return (code 13)
>- tab (code 9)
>- cursor (codes around 28 to 31)
>- page up/down
>- delete key (code maybe 127)
>and some more

I agree.  The solution I've used before is to build an array filled with
boolean values indicating whether a particular key should be accepted or
not.  Then you just do something like this:

  if not keysTable(asc(key)) then
    return true
  end if

Or, depending on how you want things set up, you could reverse the
booleans and do something like this:

  return keysTable(asc(key))

-Thomas

Personal web page:                 http://home.earthlink.net/~thomasareed/
My shareware:            http://home.earthlink.net/~thomasareed/shareware/
Pixel Pen web pub. guide: http://home.earthlink.net/~thomasareed/pixelpen/

I won't rise to the occasion, but I'll slide over to it.



<Prev in Thread] Current Thread [Next in Thread>