Page 1 of 1
Single line text entry field
Posted: Thu Jun 13, 2013 2:17 pm
by mannby
Hello all!
I want the text entry field to only accept a single line, but I can't
find the property for that. At the moment when I type a value into a field and
press enter then the cursor continues to the next line.
Regards
Roger
Re: Single line text entry field
Posted: Thu Jun 13, 2013 2:37 pm
by Klaus
Hi Roger,
1. welcome to the forum!
2. add an empty "dummy" script to the field(s) that will catch RETURN and ENTER like this:
Code: Select all
on returninfield
## Nada :-)
end returninfield
on enterinfield
## Also NADA :-)
end enterinfield
If you do not "pass enterinfield" etc. the message will disappear into data nirvana
Best
Klaus
Re: Single line text entry field
Posted: Thu Jun 13, 2013 3:00 pm
by mannby
Thanks for your fast reply Klaus!
I will try this, but have the behavior of the text entry field changed in the later
versions of LiveCode? I was reading a lesson from 2011 I think, explaining the "field" tool
and there it says that the label field and the text entry field was for single line text.
Regards
Roger
Re: Single line text entry field
Posted: Thu Jun 13, 2013 3:14 pm
by Klaus
Hi Roger,
there is only ONE type of field in Livecode!
The Tools palette does "only" offer fields with some "pre-setup" properties, which make them look different.
Know what I mean? Example: A "listfield" is just a plain field with its "listbehavior" property (and some more) set to to TRUE etc...
Best
Klaus
Re: Single line text entry field
Posted: Thu Jun 13, 2013 6:18 pm
by jacque
You may be thinking of the autotab property (you may have the inspector set up to call it "tab on return".) Set it to true and a return or enter will move the cursor to the next field. To make that work, be sure the field height is sized to hold only one line of text.
Re: Single line text entry field
Posted: Thu Jun 13, 2013 6:43 pm
by Klaus
Oh, yes, or set the fields "autotab" to true

Re: Single line text entry field
Posted: Thu Jun 13, 2013 7:15 pm
by jacque
LOL! I knew you knew that Klaus.

Re: Single line text entry field
Posted: Fri Jun 14, 2013 7:17 am
by mannby
Thanks for the help Klaus and Jacque!
Roger
Re: Single line text entry field
Posted: Mon Jan 06, 2014 9:34 pm
by pderocco
I know this topic is a bit stale, but I discovered another issue: even if you trap enter/return, you can still paste multi-line text into the field. To prevent this, you need to trap pasteKey as well. (And BTW, pasteKey doesn't get trapped in the IDE unless you suspend development tools.)
Since no one earlier in this thread thought of that, I'm not sure there isn't some other sneaky way to inject multiple lines into a text field. This suggests to me that there really should be a built-in attribute that enforces single-line behavior, so we don't have to write three dummy scripts (and worry that there's something we missed).
Re: Single line text entry field
Posted: Mon Jan 06, 2014 9:38 pm
by FourthWorld
on textChanged
replace cr with space in me
end textChanged