How to safely set the icon of a button ?
J. Landman Gay
jacque at hyperactivesw.com
Sun Feb 27 15:03:42 EST 2005
Even if you use an image's short name as an icon reference, the engine
will try to resolve that into an image ID number. Under the hood, only
ID numbers can be assigned as icons. So I'm guessing your image IDs
duplicate some of those in the Rev IDE. Since it is possible to assign
an ID to an image (they are the only controls that allow this, and it is
for this exact reason) just assign a different ID to the images that
On 2/27/05 1:26 PM, Alex Tweedly wrote:
> 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
>> 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.
>> 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"
>> set the icon of button "Heap" to "s1"
>> set the label of me to "Show it"
>> end if
>> end mouseUp
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the Use-livecode