Rename an Icon?

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

pugalug
Posts: 15
Joined: Mon Jan 29, 2024 9:19 pm

Re: Rename an Icon?

Post by pugalug » Mon Mar 25, 2024 7:19 pm

bn wrote:
Mon Mar 25, 2024 11:13 am
Hi Pugalug,
I have imported as control some image files and saved them to a separate card in my stack. I want to use these images as button icons. I am making a spinner game and the id of the images keeps changing
You could name your images like "horse1", "horse2" etc. and then

Code: Select all

set the icon of button "myHorseButton" to the short id of image  "horse1" of card "myImages"

Code: Select all

set the icon of button "myHorseButton" to the short id of image  "horse2" of card "myImages"
Kind regards
Bernd
Thank you. I am going to try this.

pugalug
Posts: 15
Joined: Mon Jan 29, 2024 9:19 pm

Re: Rename an Icon?

Post by pugalug » Mon Mar 25, 2024 7:25 pm

dunbarx wrote:
Mon Mar 25, 2024 2:47 pm
I imported an image onto a card and recorded the ID that LC assigned to it: 1003

I then cut the image and immediately pasted it. The ID of that image was 1006.

This all makes sense to me. The IDE creates ID's as controls are created, without any thought to maintaining their original assignments. It obviously keeps track of previous assignments, and cares nothing about the fact that it is the very same control put back in the very same location. But is that sort of thing the issue is here?

Craig
Yes, I think this is what is going on. The only thing is I did not cut or paste the image at all. The icon IDs are changing anyway. I DID copy and paste the buttons the different icons would end up on. Could that be the reason the icon IDs are changing? Thank you!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9999
Joined: Wed May 06, 2009 2:28 pm

Re: Rename an Icon?

Post by dunbarx » Mon Mar 25, 2024 7:44 pm

Hi.

The ID of one control will not change whatever you do to any other. I believe we are all pretty sure about that. Ironically, what LC touts as an unchangeable and invulnerable property (the ID) seems not to be in your setup. There has to be something else going on. This issue has never come up before.

So you have two paths. First, stay with your current work and try to figure out why the ID's are (seem to be) unstable.

Second, and I recommend this, change all your control references to name references. They are far more descriptive, do not change at all on their own, and as others have pointed out, can be named with the idea of keeping similar or related controls "together" in "groups". I do this all the time, with some naming schemes running into hundreds.

It hopefully will not take long to completely switch over. Just search for every case sensitive instance of "ID" in all your scripts so you do not miss any.

It may or may not then be of any interest for you to ferret out what is going on with those pesky ID's.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9999
Joined: Wed May 06, 2009 2:28 pm

Re: Rename an Icon?

Post by dunbarx » Mon Mar 25, 2024 7:53 pm

Have you noted the succession of changed ID's? In other words, if you copy and paste (or clone) a control the new ID will follow closely if not perfectly the ID of the lastmost created control. Do yours do that?

You can use the "newImage" message to find out. That is sent each time a new image is created, pasted, whatever. I am assuming that these rogue images with "new" ID's will come along with that message .

Craig

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9999
Joined: Wed May 06, 2009 2:28 pm

Re: Rename an Icon?

Post by dunbarx » Mon Mar 25, 2024 8:00 pm

And you can set an alarm to go off whenever a "newImage" message is sent. Just trap it in the stack script:

Code: Select all

on newImage
  beep until the optionkey is down
end newimage
Make sure your sound is turned up loud. :D

Craig

stam
Posts: 2990
Joined: Sun Jun 04, 2006 9:39 pm

Re: Rename an Icon?

Post by stam » Mon Mar 25, 2024 8:52 pm

pugalug wrote:
Mon Mar 25, 2024 7:18 pm
stam wrote:
Mon Mar 25, 2024 12:21 pm
The OP's issue was that the ID he was using appears to be changing. The naming is a different issue.
I'm not aware this can happen unless the image has been duplicated/pasted - but perhaps I'm wrong.

S.
Yes. This is what is happening. I haven't duplicated or pasted the icon BUT I did duplicate the three buttons. Could that have something to do with the icon names changing?
Not sure that makes sense...
If you are referencing the ID, this can ONLY change if the image is copy/pasted or duplicated. Otherwise the ID is largely immutable. However I'm not sure that's what you're talking about, since you mention icon names (not icon IDs)

you could share a tiny stack exemplifying your issue, sometimes it becomes clearer then...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9999
Joined: Wed May 06, 2009 2:28 pm

Re: Rename an Icon?

Post by dunbarx » Mon Mar 25, 2024 8:57 pm

Stam.

(s)he ??

Certainly compact, but these days does not cover all bases...

Craig

stam
Posts: 2990
Joined: Sun Jun 04, 2006 9:39 pm

Re: Rename an Icon?

Post by stam » Mon Mar 25, 2024 9:13 pm

dunbarx wrote:
Mon Mar 25, 2024 8:57 pm
Stam.

(s)he ??

Certainly compact, but these days does not cover all bases...

Craig
adding "it" to the end of (s)he is likely to cause offence ;)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9999
Joined: Wed May 06, 2009 2:28 pm

Re: Rename an Icon?

Post by dunbarx » Mon Mar 25, 2024 9:14 pm

Pugalug

What Stam said. Please be careful. Mixing "name" and " ID" makes it difficult to determine what is really going on...

How did you find out that referencing an image (or an icon?) caused a problem? Was it that the wrong control appeared, different from what you expected?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9999
Joined: Wed May 06, 2009 2:28 pm

Re: Rename an Icon?

Post by dunbarx » Mon Mar 25, 2024 9:17 pm

Stam.

Are you from the South? I was once. Anyway, I know you are not, so I will inform you that what you just mentioned would be spelled, and pronounced, "sheeit".

Craig

stam
Posts: 2990
Joined: Sun Jun 04, 2006 9:39 pm

Re: Rename an Icon?

Post by stam » Tue Mar 26, 2024 2:53 am

Yes Craig.
That’s why I mentioned it may cause offence and I don’t use this.

(S)he is but the smallest compromise in trying to address someone whose gender is not evident by their chosen username. And yes, I do like my code compact ;)

Iif that’s not good enough, they should put their desired pronouns in their signature and I would respect that.

But I am not gonna list every possible pronoun ;)
And definitely not using (s)he-it ;)

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

Re: Rename an Icon?

Post by richmond62 » Tue Mar 26, 2024 9:07 am

Why not just use 'They' and 'them' and then whatever anyone's gender is, was, is imagined to be, and so on, should not matter at all?

stam
Posts: 2990
Joined: Sun Jun 04, 2006 9:39 pm

Re: Rename an Icon?

Post by stam » Tue Mar 26, 2024 9:22 am

richmond62 wrote:
Tue Mar 26, 2024 9:07 am
Why not just use 'They' and 'them' and then whatever anyone's gender is, was, is imagined to be, and so on, should not matter at all?
I only use plural form for members of the Royal family ;)

On a more serious note: One is not many.
He or she or it or dolphin is not “they”. If people are easily offended because preferred to be called dolphin they should make it clear. It’s up to them, not me, to inform.

I’m not going to guess and unless I know better I will use the pronouns for biological sex, not some unknown self-assigned gender. Hence instead of “He or she” I’ll write (s)he. Unless I’m informed otherwise, in which case, no problem.

If that offends, it may be a sign of needing to get out more.

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

Re: Rename an Icon?

Post by richmond62 » Tue Mar 26, 2024 9:55 am

As English is one of my 2 native languages, and as I make my 'bread and cheese' by teaching English as a Foreign language, I have learnt that Grammatical Purism can only go so far: after all, the creepy people who write Prescriptive Grammar books need to get out more.

And if you ain't sure about that . . .

Certainly a "quick spin round the internet" will show you that the use of 'they' and 'them' as a singular has been in common parlance (i.e. English-as-she-is-used rather than what some stuffed-shirt has handed down from on high as how-it-should-be-used), as well as, interestingly enough "themself" (which does make my toes curl up).

I am sure that the use of 'them' and 'they' as singular forms came into use when people worked out that when you meet a bearded lady in the supermarket and want to tell your, err, "significant other" about that event lady you don't really want to spend 15 minutes fishing for some appropriate personal pronoun.

When I signed up to Facebook I was given a choice of 57 genders to choose from: and my reaction was "Who has been so clever to fool the Facebook people into employing them to cook up all than nonsense?"

stam
Posts: 2990
Joined: Sun Jun 04, 2006 9:39 pm

Re: Rename an Icon?

Post by stam » Tue Mar 26, 2024 10:41 am

Perhaps both you and others need to have critical think about what you're posting here.

This is as you know a programming forum, not the grammar/syntax/political correctness policing headquarters.

The fact that you and Craig expend so much energy about my use of 3 letters says more about you than you obviously realise.
I have never used an ignore list before, so I guess you should feel honoured, because frankly I've had enough now.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”