Single line text entry field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
mannby
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3
Joined: Sun Jan 22, 2012 5:54 pm

Single line text entry field

Post by mannby » Thu Jun 13, 2013 2:17 pm

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Single line text entry field

Post by Klaus » Thu Jun 13, 2013 2:37 pm

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

mannby
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3
Joined: Sun Jan 22, 2012 5:54 pm

Re: Single line text entry field

Post by mannby » Thu Jun 13, 2013 3:00 pm

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Single line text entry field

Post by Klaus » Thu Jun 13, 2013 3:14 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Single line text entry field

Post by jacque » Thu Jun 13, 2013 6:18 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Single line text entry field

Post by Klaus » Thu Jun 13, 2013 6:43 pm

Oh, yes, or set the fields "autotab" to true :-D

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Single line text entry field

Post by jacque » Thu Jun 13, 2013 7:15 pm

LOL! I knew you knew that Klaus. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

mannby
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3
Joined: Sun Jan 22, 2012 5:54 pm

Re: Single line text entry field

Post by mannby » Fri Jun 14, 2013 7:17 am

Thanks for the help Klaus and Jacque!

Roger

pderocco
Posts: 44
Joined: Fri May 16, 2008 1:26 am

Re: Single line text entry field

Post by pderocco » Mon Jan 06, 2014 9:34 pm

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).
Ciao,
Paul

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Single line text entry field

Post by FourthWorld » Mon Jan 06, 2014 9:38 pm

on textChanged
replace cr with space in me
end textChanged
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply