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
-
richmond62
- Livecode Opensource Backer

- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Sat Jun 15, 2019 4:32 pm
So; messing around getting stuff ready for my intro classes that start on Monday
I ran up this stack:
-
-
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.
-
Attachments
-
- ANTS.livecode.zip
- Here's the stack
- (29.66 KiB) Downloaded 250 times
-
[-hh]
- VIP Livecode Opensource Backer

- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
Post
by [-hh] » Sat Jun 15, 2019 6:18 pm
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
shiftLock happens
-
richmond62
- Livecode Opensource Backer

- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Sun Jun 16, 2019 8:16 am
You could make it "unique"
Indeed, but that completely
misses my point.
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.
-
jmburnod
- VIP Livecode Opensource Backer

- Posts: 2729
- Joined: Sat Dec 22, 2007 5:35 pm
-
Contact:
Post
by jmburnod » Sun Jun 16, 2019 11:59 am
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
https://alternatic.ch
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7392
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Sun Jun 16, 2019 5:41 pm
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
richmond62
- Livecode Opensource Backer

- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Sun Jun 16, 2019 7:12 pm
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.

-
Klaus
- Posts: 14196
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Sun Jun 16, 2019 7:42 pm
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")
...

-
jacque
- VIP Livecode Opensource Backer

- Posts: 7392
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Sun Jun 16, 2019 7:43 pm
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
bogs
- Posts: 5480
- Joined: Sat Feb 25, 2017 10:45 pm
Post
by bogs » Sun Jun 16, 2019 8:04 pm
He is on fire today, as usual.
{Throwing a bucket of water over Klaus}
JUST KIDDING@