Page 1 of 1

Counter Intuitive

Posted: Sat Jun 15, 2019 4:32 pm
by richmond62
So; messing around getting stuff ready for my intro classes that start on Monday
I ran up this stack:
-
ants.png
-
Which contains this code in the cardScript:

Code: Select all

on arrowKey AK
   switch AK
      case "up"
         set the backGroundPattern of grc "MRAVKA" to the id of img "antUP.png"
         set the icon of btn "KOPCHE" to "antUP.png"
         break
         case "down"
         set the backGroundPattern of grc "MRAVKA" to the id of img "antDN.png"
         set the icon of btn "KOPCHE" to "antDN.png"
         break
         case "left"
         set the backGroundPattern of grc "MRAVKA" to the id of img "antLF.png"
         set the icon of btn "KOPCHE" to "antLF.png"
         break
         case "right"
         set the backGroundPattern of grc "MRAVKA" to the id of img "antRT.png"
         set the icon of btn "KOPCHE" to "antRT.png"
         break
   end switch
end arrowKey
which is "all very charming" until you realise why I spent 10 minutes cursing Marduk . . .

To set the backGroundPattern of a graphic one uses:
to the id of img "WhatDyeCallit.png"

But to set the icon of a button uses: to "WhatDyeCallit.png"

without pointing out that "WhatDyeCallit.png" is an image.

Re: Counter Intuitive

Posted: Sat Jun 15, 2019 6:18 pm
by [-hh]
You could make it "unique", for example as follows.

Code: Select all

on arrowKey AK
  switch AK
    case "up";    put the id of img "antUP.png" into N; break
    case "down";  put the id of img "antDN.png" into N; break
    case "left";  put the id of img "antLF.png" into N; break
    case "right"; put the id of img "antRT.png" into N; break
  end switch
  set the backGroundPattern of grc "MRAVKA" to N
  set the icon of btn "KOPCHE" to N
end arrowKey

Re: Counter Intuitive

Posted: Sun Jun 16, 2019 8:16 am
by richmond62
You could make it "unique"
Indeed, but that completely misses my point. 8)

The fact is that objects should always be referred to by their type and their name,
and when setting the icon of a button that does NOT happen.

This is both inconsistent, and because everywhere else images are referred to as images
counter intuitive.

For those of us at the pointy end of teaching LiveCode this is a bit of a pain in the bum.

Re: Counter Intuitive

Posted: Sun Jun 16, 2019 11:59 am
by jmburnod
Hi Richmond,
This is both inconsistent, and because everywhere else images are referred to as images
counter intuitive.
Yes, but pattern is pattern and icon is icon
Your students can see the difference between them and choose the better control to build what they want.
Best
Jean-Marc

Re: Counter Intuitive

Posted: Sun Jun 16, 2019 5:41 pm
by jacque
They are consistent in that both accept ID numbers. In fact, that's all an icon would accept until the image name was added later as a convenience.

If you want to teach just one thing, use I'Ds only at first.

Re: Counter Intuitive

Posted: Sun Jun 16, 2019 7:12 pm
by richmond62
image name was added later as a convenience
That must have been in the Paleolithic.

ID numbers mean that kiddos have to go and look them up . . .

. . . But the "I want it now, or, preferably sooner" generation find that a bit tough. 8)

Re: Counter Intuitive

Posted: Sun Jun 16, 2019 7:42 pm
by Klaus
richmond62 wrote:
Sun Jun 16, 2019 7:12 pm
ID numbers mean that kiddos have to go and look them up . . .
Then use:

Code: Select all

... 
set the icon of btn x to (the ID of image "whatever.png")
...
8)

Re: Counter Intuitive

Posted: Sun Jun 16, 2019 7:43 pm
by jacque
ID numbers mean that kiddos have to go and look them up .
If you want consistency just use "the ID of img x" everywhere.

The point being that the two are consistent, but one offers an alternative reference.

Edit: I see that speedy Klaus has beat me to it.

Re: Counter Intuitive

Posted: Sun Jun 16, 2019 8:04 pm
by bogs
He is on fire today, as usual.
{Throwing a bucket of water over Klaus} :wink:

JUST KIDDING@