Storing Images for use by Custom Controls

Bob Sneidar bobsneidar at iotecdigital.com
Tue Jul 24 18:14:39 CEST 2018


I have a custom control group with a series of buttons, each with an enabled icon and a disabled icon. I have this if the group script, which should give you some idea how to proceed:

on newBackground
   -- Relink buttons to graphics as they all have different ID's now
   set the icon of button "btnNew" to the short id of image "imgNew"
   set the disabledIcon of button "btnNew" to the short id of image "imgNewDisabled"
   set the icon of button "btnDelete" to the short id of image "imgDelete"
   set the disabledIcon of button "btnDelete" to the short id of image "imgDeleteDisabled"
   set the icon of button "btnEdit" to the short id of image "imgEdit"
   set the disabledIcon of button "btnEdit" to the short id of image "imgEditDisabled"
   set the icon of button "btnCancel" to the short id of image "imgCancel"
   set the disabledIcon of button "btnCancel" to the short id of image "imgCancelDisabled"
   set the icon of button "btnSave" to the short id of image "imgSave"
   set the disabledIcon of button "btnSave" to the short id of image "imgSaveDisabled"
   set the icon of button "btnHome" to the short id of image "imgHome"
   set the disabledIcon of button "btnHome" to the short id of image "imgHomeDisabled"
   pass newBackground
end newBackground

In retrospect I should have created a loop, but that would depend on the image names being predictable. As you can see I have named all my icons in such a way so as to reflect the name of the button itself. If you do that, this could be made into a generic handler that would work for any group with buttons next to their icon images, and you wouldn't need to use literals. 

Bob S


> On Jul 24, 2018, at 08:44 , Simon Knight via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Is there an elegant method of storing images for use by a custom control?  I have tried adding the images to the custom control group but the buttons in copies of the first group refer back to the first group so there is no advantage when compared to storing the images on a card or in a folder.
> 
> best wishes
> 
> Simon K.




More information about the use-livecode mailing list