How to safely set the icon of a button ?

Alex Tweedly alex at tweedly.net
Sun Feb 27 14:26:55 EST 2005


I have a stack (intended to be a "library" stack), which contains a 
number of images.

The application stack that uses this library sets the icon of its 
buttons to one of the images (it uses a function in the library to do it).

The problem is that one (and only one) of the images comes up wrong; 
instead of showing my images, it shows the Dreamcard splash screen. If I 
look at it with the inspector, it only shows the id of the icon - which 
is the correct number to be mine (but see the extract from the docs 
below). 

If I load the stack(s) into Rev 2.2.1, then again exactly one button 
gets the wrong image (it's a different one), this time showing the image 
from the Revolution splashcard.

The docs say

> Value:
> The icon is the short ID or short name of the image to use for the 
> current application's dock icon. The icon of a button or stack is also 
> a short name or ID of an image.
>
> By default, the icon property is set to zero (no icon). The icon of 
> newly created buttons and stacks is set to zero (no icon) by default.
>
> Comments:
> Revolution looks for the specified image first in the current stack, 
> then in other open stacks.
>
Note - it's the *SHORT* name - so in my case the one that goes wrong is 
image "s1" (for Dreamcard 2.5), or "hq" (for Rev 2.2)

It seems unlikely that any Rev stack has images called "s1" and "hq" - 
though it might be possible.

Any suggestions for how I can tell what's happening ?

I managed to build a tiny app to demo the problem - this works fine in 
2.2 but shows the Dreamcard splashscreen on DC2.5
Here's the (only) script from my test app ... on a button

> global  gHeapId
>
> on mouseUp
>   local tPath
>  
>   put the filename of this stack into tPath
>   set the itemDel to "/"
>   put "Playing Cards.rev" into  item -1 of tPath
>   start using stack tPath
>  
>   put the long ID of button "Heap" into gHeapID
>   set the width of button "Heap" to 71
>   set the height of button "Heap" to 96
>   set the cRemaining of button "Heap" to empty
>   set the visible of button "Heap" to true
>  
>  
>   if the label of me = "Show it" then
>     set the icon of button "Heap" to 0
>     set the label of me to "Hide it"
>   else
>     set the icon of button "Heap" to "s1"
>     set the label of me to "Show it"
>   end if
>  
> end mouseUp

-- 
Alex Tweedly       http://www.tweedly.net




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 266.5.0 - Release Date: 25/02/2005



More information about the use-livecode mailing list