Editable 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
garyth123
Posts: 88
Joined: Sat Apr 27, 2013 11:14 am
Contact:

Editable field

Post by garyth123 » Mon Oct 21, 2013 4:34 pm

Hi,

Would it be possible to do something like the following: have an editable text field in which the user may enter some text (eg the answer to a question in a quiz). On pressing return the user's answer is checked against the stored answer (this is a really simple quiz so the two should match if the user has got it correct), and notify the user of success/failure and then update their score accordingly.

I would like to do this from the field rather than have the user enter an answer in a field then click a button to check their answer. However as I understand it a field needs to have its lock property set to false in order to be editable. But it needs to be locked in order to receive messages which get it to do something.

I've looked at returnKey, and returnInField but the penny is not dropping, so any help would be much appreciated.

Thanks in advance.

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

Re: Editable field

Post by Klaus » Mon Oct 21, 2013 4:40 pm

Hi garyth123,

just add this script to an editable field and see what happens when you hit RETURN or ENTER:

Code: Select all

on returninfield
  answer "End of editing :-)"
  ## Or do whatever you want to now!
end returninfield

## Also "catch" the ENTER key:
on enterinfield
  returninfield
  ## Too lazy to write the RETUNINFIELD handler again :-)
end enterinfield
Best

Klaus

Post Reply