Stop user pressing Enter in entry field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 50
- Joined: Thu Apr 19, 2018 6:18 am
Stop user pressing Enter in entry field
Hi there
I would like to know how to stop the user of my program from pressing the Enter or Return Key for a new line in text entry fields as I only want them to be able to provide 1 line of text. How do I do this please?
I would like to know how to stop the user of my program from pressing the Enter or Return Key for a new line in text entry fields as I only want them to be able to provide 1 line of text. How do I do this please?
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Stop user pressing Enter in entry field
Hi.
Try this in the field script:
LC will never see messages like "returnInField" that it uses to er, return in a field.
Craig Newman
Try this in the field script:
Code: Select all
on returnInfield
end returnInfield
on enterInField
end enterInField
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Stop user pressing Enter in entry field
Alternately, size the height of the field to hold only one line and set the autotab of the field to true in the property inspector.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 50
- Joined: Thu Apr 19, 2018 6:18 am
Re: Stop user pressing Enter in entry field
Thanks guys
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Stop user pressing Enter in entry field
If that solution is not exciting enough for you, you can try this:
-
-
case 65293 traps the RETURN key (marked in powder blue).
case 65421 traps the ENTER key (marked in pale green).
The reason for this is that to trap BOTH in the way previously suggested you would
have to use
returnInField and
enterInField.
As the initial question was about stopping people pressing the ENTER key and NOT the RETURN key . . .
Being pedantic is such sweet joy.
Code: Select all
on rawKeyDown RK
switch RK
case 65293
--do nix
break
case 65421
--do nix
break
default
pass rawKeyDown
end switch
end rawKeyDown
case 65293 traps the RETURN key (marked in powder blue).
case 65421 traps the ENTER key (marked in pale green).
The reason for this is that to trap BOTH in the way previously suggested you would
have to use
returnInField and
enterInField.
As the initial question was about stopping people pressing the ENTER key and NOT the RETURN key . . .
Being pedantic is such sweet joy.
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Stop user pressing Enter in entry field
Richmond.
I was accused, but never convicted of pedantism.
Howeveer, the OP originally did indeed ask to stop both "enter" and "return".
Craig
I was accused, but never convicted of pedantism.
Howeveer, the OP originally did indeed ask to stop both "enter" and "return".
Craig
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Stop user pressing Enter in entry field
I am both accused and convicted.the Enter or Return Key
HOWEVER: returnInField will ONLY trap the RETURN key.
https://youtu.be/HDMV4UF_-Rs
-
- VIP Livecode Opensource Backer
- Posts: 9665
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Stop user pressing Enter in entry field
Right. As it should.HOWEVER: returnInField will ONLY trap the RETURN key.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Stop user pressing Enter in entry field
Whenever possible I let the engine do it. This functionality is built in and requires no code.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com