Storing Images for use by Custom Controls

Simon Knight smk at anvic.net
Wed Jul 25 16:20:59 EDT 2018


Hi Bernd,

Unfortunately when I tried your code the copies referred back to the original.

best wishes

Simon
> On 25 Jul 2018, at 13:22, BNig via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Hi Simon,
> 
> I think the easiest way would be to copy the images your custom control uses
> to the custom controls. 
> then add this code to the group (it is for one button "bOne" and two images
> "greenRound" and "redQMark"
> 
> on newGroup
>   resolve image "redQMark" relative to button "bOne" of me
>   if it is not empty then 
>      set the hilitedIcon of button "bOne" to the short id of it
>   end if
>   resolve image "greenRound" relative to button "bOne" of me
>   if it is not empty then 
>      set the icon of button "bOne" to the short id of it
>   end if
> end newGroup
> 
> "NewGroup" is a message that the custom control gets when you paste it.
> That way the custom control is self contained and when you paste it into a
> new stack it will assign the ids of the images to your buttons.
> 
> Kind regards
> Bernd
> 
> That way they are contained in your custom control and the custom control
> can be self contained, i.e. can be reused in a different stack.
> 
> 
> Simon Knight via use-livecode wrote
>> Hi Scott,
>> 
>> Thank you for your replies.  I apologise for my question, I should have
>> been clearer.  However, I have copied your response to my “hints and tips”
>> document for reference in the future as it seems like a useful workflow to
>> know.
>> 
>> To clarify my question; I have created a simple custom control that uses
>> two list fields and some buttons.  I will probably want to use the control
>> in the future so I am seeking a method of saving the control ready to be
>> used in the future.  At the moment the png images, I use to "skin" the
>> buttons, are stored on a card on a sub-stack named assets.  I do this
>> because I am following some advice that Trevor Devore gave in a video some
>> years ago and I know no better.  
>> 
>> The problem with this storage solution is that my custom control has
>> components stored in different locations and they may well become
>> separated sometime in the future.
>> Initially, I searched the Livecode forum and found a thread where the
>> prospect of better encapsulation of custom controls was discussed and Mark
>> W. wrote that he was thinking  about it.  This was a few years ago when
>> version 6 was current and I wondered if any features have been added to
>> Livecode to enable fully encapsulated custom controls to be written.  I
>> realise that one answer might be “write a widget” but I don’t really want
>> to take time learning a new language and process in an attempt to recreate
>> a control that I already have.
>> 
>> I had not thought of using a customProp to store images and in truth I did
>> not know it was an option so I will do some research and see what I can
>> learn.
>> 
>> Thanks again and best wishes
>> 
>> Simon
> 
> 
> 
> 
> 
> --
> Sent from: http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list