Linking Multiple Text Entry Fields
by Gary Rosenzweig
|
Have you ever seen a set of text entry fields that are linked together so the user can just type right from one to the other? You might see this done for fields that let the user type a product serial number, a telephone number, or even a zip+4 code. If you are still not sure what I am talking about, check out this week's example movie below.
These are just three regular text members set to editable and tab to next item. However, I have added Lingo code so that the insertion point immediately follows from one text member to the next after the maximum number of characters have been entered. I've also customized the fields so that only numerical digits can be entered, three in the first two boxes, and four in the last. The behavior I wrote to do this follows. The comments explain each section of code. I've allowed for customization, so numbers, letters, or additional characters can be specified. The getPropertyDescriptionList handler also determines how many characters will be allowed in the text member sprite.
property s on getPropertyDescriptionList
me on beginSprite
me on keyDown
me
-- check to see if it is a number
-- check to see if it is a letter
-- see if it is another type of character
-- whatever happens, don't exceed max char
-- pass teh characer if it is allowed on keyUp
me
To use this code to link together text members, you need to place it on each of the text member sprites. Then, you need to make sure that they are in consecutive sprite channels. Check the example movie if you want to see how it fits together. I know this isn't the most exciting piece of code, but it can serve a purpose in the right application. It will certainly help a confused user to enter the right type of data. A sample Director 8 movie is available for download in Mac or Windows format. Gary Rosenzweig's two most recent books are:
|