Text only in field

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

Text only in field

Post by reelstuff » Mon Sep 22, 2008 3:25 am

I have a card that requires the user to enter some text to fill out some variables in a form.

I encountered a problem where the user could hit the return key,
placing a CR after the entered text.

I am guilty of doing this myself, while filling out forms, most of the time it would not matter however in this case, a CR is not wanted.

I began to wonder if there were a way to make sure that there is not a CR in the field, as the rest of the script depends on each line of the script to be on its own line.

So a CR in a text field, would create a new line where it is not wanted, which breaks the script.

Any thoughts on this, I tried a couple of different things, but it appears that even if you use the IF statement the field will still accept a CR.

Thanks in advance for any suggestions.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Mon Sep 22, 2008 6:33 am

The easiest method is to set the 'autoTab' property of the field to true. This way the engine will automatically 'tab' to the next field if the user enters a CR into the field.
Note that you can still allow multiple lines in such a field by tweaking the height: if two lines would fit without causing the text to 'scroll up' then the return won't send the focus to the next field until the user hits CR a second time.
Also look at the 'returnInField' and 'enterInField' messages in the Revolution dictionary.

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Contact:

thank you

Post by reelstuff » Mon Sep 22, 2008 10:43 am

Thanks Jan the answer was literally right in front of my face, LOL.

Post Reply