Leon,

In your code, if the user types a symbol (pound sign for example 
where the key = 35), it will fall through all your case tests and 
land in the otherwise clause.  The code of the otherwise clause is 
"pass".  Pass means to pass this key through to the field - which is 
exactly what is happening.  If you do not want to pass such 
characters, use "dontPassEvent"

One extra style comment.  Instead of repeating "chartonum(the key)" 
in so many places, do it once at the top of you keydown handler, 
assign the result to a local variable, then use the local variable 
everywhere:

   keyValue = charToNum(the key)
   case TRUE of
     (keyValue = 13): -- RETURN
        submitWord(me)
     etc.

While the results will be unnoticable in such a short handler, it 
does make the code more readable, and is a good tehnique will speed 
up code in general.

Irv


At 4:51 PM +0100 5/15/01, Leon McComish wrote:
>Hi all,
>
>I have 2 editable textfields on a screen (whilst testing). The first 
>is editable and accepts input from the user. The user is a 
>concatenation of the authorised keys pressed.
>
>Code attached to text field one checks the keydown against a case 
>statement, checks to see that the key is a letter (using 
>charToNum(the key)) and if so displays it and adds it to the second 
>text box (only for testing - won't be on screen eventually - 
>probably a variable).
>
>It works perfectly for passing the correct keys to the 2nd field but 
>not to itself.
>e.g. press a or A and it will allow it (and capitalize it), display 
>it AND pass it to the second field.
>BUT, enter a number or a symbol (",.@'#~) and, correctly, it doesn't 
>pass it to the 2nd field BUT, incorrectly, does display it in itself.
>
>I'm sure I'm doing something wrong. The code's below. Have I got 
>something in the wrong order or is there something to do with fields 
>that I don't know?
>
>------------------------CODE BEGINS--------------------------
>property sNum
>
>on beginsprite me
>   sNum = me.spritenum
>   set the text of sprite(sNum).member to ""
>   set the text of member "CurrentWord" to ""
>end
>
>on keyDown me
>   put chartonum(the key)
>   case (true) of:
>     (chartonum(the key) = 13):--RETURN
>       submitWord(me)
>     ((chartonum(the key) > 64) AND (chartonum(the key) < 91)): -- A-Z
>       pKeycode = chartonum(the key)
>       charadder(me, pKeycode)
>     ((chartonum(the key) > 96) AND (chartonum(the key) < 123)): -- a-z
>       capitalize (me, pKeycode)
>       pKeycode = the result
>       charadder(me, pKeycode)
>     otherwise:
>       pass
>   end case
>end
>
>on charAdder me, pKeycode
>   member("Entry").text = member("Entry").text & NumtoChar(pKeycode)
>   member("CurrentWord").text = member("CurrentWord").text & 
>NumtoChar(pKeycode)
>end
>
>on capitalize me, pKeycode
>   UpperToReturn = pKeycode - 32
>   return UpperToReturn
>end
>
>------------------------CODE ENDS--------------------------
>
>I believe I'm 'controlling' the input allowed through the CASE 
>statement and the use of OTHERWISE. Am I wrong?
>
>TIA
>
>Leon
>
>
>
>[To remove yourself from this list, or to change to digest mode, go to
>http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
>email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
>Lingo-L is for learning and helping with programming Lingo.  Thanks!]


-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to