Small boys teaching me LiveCode

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Small boys teaching me LiveCode

Post by richmond62 » Fri Oct 08, 2021 5:19 pm

Indeed . . .

I got this via Viber today from an 11 year old:
-
SShot 2021-10-08 at 19.14.29.png
-
Which "threw me off" quite a bit as I ALWAYS (in my EFL programs) use a Tick image for end users to check a field's contents.

I had never used the RETURN key, and had never worked out how to.

SO . . . to the much-maligned built-in Dictionary and found on ReturnInField, which, was, frankly, like being handed the keys to
the Holy Kingdom on a plate:

Code: Select all

on returnInField
   if fld "ff" contains "black" then
      set the vis of img "YES" to true
      set the vis of img "NO" to false
   else
      set the vis of img "YES" to false
      set the vis of img "NO" to true
   end if
   if fld "ff" is empty then
      set the vis of img "YES" to false
      set the vis of img "NO" to false
   end if
end returnInField
-
SShot 2021-10-08 at 19.10.52.png
-
SShot 2021-10-08 at 19.11.08.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: Small boys teaching me LiveCode

Post by richmond62 » Fri Oct 08, 2021 5:21 pm

SShot 2021-10-08 at 19.11.14.png
-
Attachments
NO.livecode.zip
Here's the stack.
(57.03 KiB) Downloaded 151 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: Small boys teaching me LiveCode

Post by richmond62 » Sat Oct 09, 2021 9:39 am

tickkkk.jpg
-
Personally I tend to use a 'Tick' button rather than returnInField. 8)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: Small boys teaching me LiveCode

Post by richmond62 » Sat Oct 09, 2021 4:26 pm

I wonder if it is possible to differentiate between the ENTER and the RETURN keys?
-
keeze.jpg
-
Of course one could differentiate by using rawKey codes:

ENTER: 65421

RETURN: 65293

BUT that misses the point somewhat.

The Dictionary offers enterKey, and enterInField.

Hitting the ENTER key in a field yields a CR (carriage return) character unless one traps for it specifically.

Code: Select all

on enterInField
   if fld "ff" contains "black" then
      set the vis of img "YES" to true
      set the vis of img "NO" to false
   else
      set the vis of img "YES" to false
      set the vis of img "NO" to true
   end if
   if fld "ff" is empty then
      set the vis of img "YES" to false
      set the vis of img "NO" to false
   end if
end enterInField

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

Re: Small boys teaching me LiveCode

Post by jacque » Sun Oct 10, 2021 5:25 pm

The Dictionary offers enterKey, and enterInField.
And also returnKey and returnInField. The easiest way to differentiate is to use both return and enter variants in the script.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Small boys teaching me LiveCode

Post by Klaus » Sun Oct 10, 2021 6:00 pm

ELSE also covers -> if fld "ff" = empty

Code: Select all

on enterInField
   if fld "ff" contains "black" then
      set the vis of img "YES" to true
      set the vis of img "NO" to false
   else
      set the vis of img "YES" to false
      set the vis of img "NO" to true
   end if
end enterInField

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: Small boys teaching me LiveCode

Post by richmond62 » Sun Oct 10, 2021 6:03 pm

ELSE also covers -> if fld "ff" = empty
If you read my code more carefully you'll see that a word that is not 'black' gives
the 'No' image, while an empty field gives no image at all.

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

Re: Small boys teaching me LiveCode

Post by Klaus » Sun Oct 10, 2021 6:16 pm

Sorry, I bow my head in shame! :oops:

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10098
Joined: Fri Feb 19, 2010 10:17 am

Re: Small boys teaching me LiveCode

Post by richmond62 » Sun Oct 10, 2021 6:20 pm

Sit opposite your teacher, learn everything he knows,
then kill him and take his place. 8)

Post Reply