button ICON

Bob Sneidar bobsneidar at iotecdigital.com
Mon Apr 22 11:10:42 EDT 2019


I guess this goes way back to a long standing conversation as to the way buttons with graphics work in the first place. Let's say you have a group with several buttons. You now want to copy it to another project. Since the graphics are ALREADY OPEN in the project you copied from the button graphics *seem* to display fine. Until you quit livecode then open the target project by itself. No graphics! 

The fix is to go back to the original project, find all the graphics (probably hidden), copy those as well to the target app, edit the icons of the buttons to now point at the NEW ID's of the graphics, and hope you don't get it wrong. 

Someone showed me a trick. First group the graphics with the buttons they belong to. Then group all your individual button groups together. Finally put something like this in your top level group script:

on newBackground
   put the childcontrolNames of me into tGroupList
   
   repeat for each line tGroup in tGroupList
      put the childControlNames of group tGroup into tControlList
      filter tControlList with "btn*"
      
      repeat for each line tButtonName in tControlList
         put char 4 to -1 of tButtonName into tControlName
         put "img" & tControlName into tEnabledImage
         put "img" & tControlName into tDisabledImage
         if there is an image tEnabledImage then \
               set the icon of button tButtonName to the short id of image tEnabledImage
         if there is an image tDisabledImage then \
               set the disabledIcon of button tButtonName to the short id of image tDisabledImage
      end repeat
   end repeat
   pass newBackground
end newBackground


> On Apr 20, 2019, at 09:36 , Klaus major-k via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Hi friends,
> 
> I have a vague memory that we can use images as icons in buttons WITHOUT 
> putting them in an image object first. Am I right or was I dreaming? :-)
> 
> Thanks for any hints.
> 
> 
> Best
> 
> Klaus
> --
> Klaus Major
> http://www.major-k.de
> klaus at major-k.de
> 
> 
> _______________________________________________
> 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