Re: Storing Images for use by Custom Controls

2018-07-26 Thread Bob Sneidar via use-livecode
Yes that is exactly it. And because of that, if LC does not "see" that first 
group before the copy, then the images will not display correctly. If the 
images are in the same stack, then there is no problem, you can make copies of 
the group as much as you want, but suppose you copied the group from one stack 
to another, like a new substack in the same mainstack, or a completely 
different mainstack? Well then, BIG problem! 

That is why I came up with the naming method. It makes the group completely 
portable. I could have gotten around the issue of the file links not being 
found by using absolute file references instead of relative ones ie. 

/Users/bobsneidar/Documents/Livecode Projects/Forms Generator 
8/Images/PlusDisabled.png 

instead of 

./Images/PlusDisabled.png

and then I could use a cetral image repository, but then the idea of skinning 
the app would not have worked without replacing the images in the central 
repository, which would affect ALL your projects that used them. 

Bob S


> On Jul 26, 2018, at 01:52 , Simon Knight via use-livecode 
>  wrote:
> 
> Bob,
> 
> The reason I went for the array rather than a naming convention such as you 
> suggest is because I have no idea how Livecode resolves the names.  I have an 
> impression that it looks at the stack and works its way up through the images 
> in ID order.  The upshot is that a button in a copy of the first group may 
> well be using images from other groups.


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Storing Images for use by Custom Controls

2018-07-26 Thread Simon Knight via use-livecode
Hi Stephen,

Why lose the quotes, the texts are literals and not variables.

Simon

> On 25 Jul 2018, at 21:41, Stephen Barncard via use-livecode 
>  wrote:
> 
> ose the quotes inside the brackets??
> 
> sqb
> 
> --
> Stephen Barncard - Sebastopol Ca. USA -

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Storing Images for use by Custom Controls

2018-07-26 Thread Simon Knight via use-livecode
Bob,

The reason I went for the array rather than a naming convention such as you 
suggest is because I have no idea how Livecode resolves the names.  I have an 
impression that it looks at the stack and works its way up through the images 
in ID order.  The upshot is that a button in a copy of the first group may well 
be using images from other groups.

I tried all sorts of syntax along the lines of image “ImgPlusButton” of this 
group but any attempts to specify the location were rejected.  My code 
associates the local image of the required name that is within the group 
container with its ID number which is allocated when the group is created.  I 
believe that the stack wide naming/ID list is also where Bernd’s code fails; 
images are indeed found but there is no guarantee that they are the images that 
are members of the group or as in one of my tests even on the same stack.

best wishes

Simon

> On 25 Jul 2018, at 22:47, Bob Sneidar via use-livecode 
>  wrote:
> 
> About saving images: I learned a long time ago, both with graphics and 
> publications development, as well as software development, to have copies of 
> resources in a subfolder of a main project folder. This has a couple 
> advantages: First of all, graphics applications can often auto-resolve 
> references if you do that. Second, in case you want to skin your app, you can 
> keep sets of graphics in other folders, then do a simple folder rename kabuke 
> dance and voila! You just reskinned your app! 
> 
> As far as the technique of grouping buttons with their image objects (I hide 
> my image objects and put them behind the button they belong to) and then 
> grouping all the control groups as one, this is a great method, and allows 
> you to programmatically dynamically update the controls as needed. 
> 
> Finally, as I mentioned, naming the images and buttons so that knowing the 
> button name makes the image name predictable eliminates the need to store 
> everything in an array for access later, although I'm sure that is a workable 
> solution as well. 
> 
> I have no problem having multiple copies of an image in my application, at 
> least for MacOS and Windows apps. They shouldn't take up too much space if 
> designed right, and the convenience of keeping the images with the buttons 
> that need them ensures my forms will ALWAYS display correctly. 
> 
> Bob S
> 
> 
>> On Jul 25, 2018, at 13:20 , Simon Knight via use-livecode 
>>  wrote:
>> 
 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.
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-25 Thread BNig via use-livecode
I am sorry to say that my solution does not work if you paste the group on
the same card. 

However Simons solution works when "of me" is added in the repeat loop 

resolve image is not granular enough to distinguish between groups. Once you
paste the group onto a different card or stack then it works.


It could also be simplified to the following code since the images for icons
of the custom control are known

on newGroup
   set the hilitedIcon of button "bOne" of me to the short id of image
"redQMark" of me
   set the icon of button "bOne" of me to the short id of image "greenRound"
of me
end newGroup

Kind regards



bnig--- via use-livecode 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" of me 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" of me 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.





--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Storing Images for use by Custom Controls

2018-07-25 Thread Bob Sneidar via use-livecode
About saving images: I learned a long time ago, both with graphics and 
publications development, as well as software development, to have copies of 
resources in a subfolder of a main project folder. This has a couple 
advantages: First of all, graphics applications can often auto-resolve 
references if you do that. Second, in case you want to skin your app, you can 
keep sets of graphics in other folders, then do a simple folder rename kabuke 
dance and voila! You just reskinned your app! 

As far as the technique of grouping buttons with their image objects (I hide my 
image objects and put them behind the button they belong to) and then grouping 
all the control groups as one, this is a great method, and allows you to 
programmatically dynamically update the controls as needed. 

Finally, as I mentioned, naming the images and buttons so that knowing the 
button name makes the image name predictable eliminates the need to store 
everything in an array for access later, although I'm sure that is a workable 
solution as well. 

I have no problem having multiple copies of an image in my application, at 
least for MacOS and Windows apps. They shouldn't take up too much space if 
designed right, and the convenience of keeping the images with the buttons that 
need them ensures my forms will ALWAYS display correctly. 

Bob S


> On Jul 25, 2018, at 13:20 , Simon Knight via use-livecode 
>  wrote:
> 
>>> 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.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-25 Thread BNig via use-livecode
Simon,

try to add "of me" like below

 repeat with x=1 to the number of images of me 
  put the ID of image x of me into tID 
  put the short name of image x of me into tName 
  put tID into ImageA[tName] 
   end repeat 

Kind regards

Bernd


scott--- via use-livecode wrote
> Well I tried using custom props but did not get very far with them.  My
> solution is to add the image files to the group and hide them behind other
> controls.  I have added the attached handler that sets the button icons to
> the values of the images in the group.  The handler should be called when
> the original control is duplicated but.  
> 
> I used the array to ensure that the handler only finds images that are
> part of the group:
> 
> on newgroup
>-- set the icons for the buttons
>   
>--build an array of refs to images in the group
>repeat with x=1 to the number of images of me
>   put the ID of image x into tID
>   put the short name of image x into tName
>   put tID into ImageA[tName]
>end repeat
>
>--now set the icons
>set the icon of button "add" of me to ImageA["imgPlus"]
>set the icon of button "SortA" of me to ImageA["imgSort"]
>set the icon of button "Delete" of me to ImageA["imgBin"]
>
>set the icon of button "SortB" of me to ImageA["imgSort"]
>set the icon of button "Remove" of me to ImageA["imgLeftArrow"]
>set the icon of button "Use" of me to ImageA["imgLeftArrow"]   
> end newgroup
>> On 24 Jul 2018, at 23:36, scott--- via use-livecode 

> use-livecode@.runrev

>  wrote:
>> 
>> Hello Simon,
>> I see I probably misunderstood what you were trying to do. With a custom
>> control I might be tempted to store the images in a customProp if I
>> wanted multiple resolutions to travel with the group object. Then do
>> something like setting the imageData of the image.
>> —
>> Scott
> 
>>> On Jul 24, 2018, at 8:44 AM, Simon Knight via use-livecode 

> use-livecode@.runrev

>  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.





--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-25 Thread Stephen Barncard via use-livecode
lose the quotes inside the brackets??

sqb

--
Stephen Barncard - Sebastopol Ca. USA -
mixstream.org

On Wed, Jul 25, 2018 at 1:20 PM, Simon Knight via use-livecode <
use-livecode@lists.runrev.com> wrote:

> 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@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@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-25 Thread Simon Knight via use-livecode
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 
>  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@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-25 Thread Simon Knight via use-livecode
Well I tried using custom props but did not get very far with them.  My 
solution is to add the image files to the group and hide them behind other 
controls.  I have added the attached handler that sets the button icons to the 
values of the images in the group.  The handler should be called when the 
original control is duplicated but.  

I used the array to ensure that the handler only finds images that are part of 
the group:

on newgroup
   -- set the icons for the buttons
  
   --build an array of refs to images in the group
   repeat with x=1 to the number of images of me
  put the ID of image x into tID
  put the short name of image x into tName
  put tID into ImageA[tName]
   end repeat
   
   --now set the icons
   set the icon of button "add" of me to ImageA["imgPlus"]
   set the icon of button "SortA" of me to ImageA["imgSort"]
   set the icon of button "Delete" of me to ImageA["imgBin"]
   
   set the icon of button "SortB" of me to ImageA["imgSort"]
   set the icon of button "Remove" of me to ImageA["imgLeftArrow"]
   set the icon of button "Use" of me to ImageA["imgLeftArrow"]   
end newgroup
> On 24 Jul 2018, at 23:36, scott--- via use-livecode 
>  wrote:
> 
> Hello Simon,
> I see I probably misunderstood what you were trying to do. With a custom 
> control I might be tempted to store the images in a customProp if I wanted 
> multiple resolutions to travel with the group object. Then do something like 
> setting the imageData of the image.
> —
> Scott
> 
> Elementary Software
> (Now with 20% less chalk dust!)
> web   http://elementarysoftware.com/
> email sc...@elementarysoftware.com
> booth 1-800-615-0867
> 
>> On Jul 24, 2018, at 8:44 AM, Simon Knight via use-livecode 
>>  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.
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-25 Thread scott--- via use-livecode
Neat! I didn’t know about resolve image.


> On Jul 25, 2018, at 5:22 AM, BNig via use-livecode 
>  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@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-25 Thread BNig via use-livecode
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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-25 Thread Simon Knight via use-livecode
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
> On 24 Jul 2018, at 23:36, scott--- via use-livecode 
>  wrote:
> 
> Hello Simon,
> I see I probably misunderstood what you were trying to do. With a custom 
> control I might be tempted to store the images in a customProp if I wanted 
> multiple resolutions to travel with the group object. Then do something like 
> setting the imageData of the image.
> —
> Scott
> 
> Elementary Software
> (Now with 20% less chalk dust!)
> web   http://elementarysoftware.com/
> email sc...@elementarysoftware.com
> booth 1-800-615-0867
> 
>> On Jul 24, 2018, at 8:44 AM, Simon Knight via use-livecode 
>>  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.
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-24 Thread scott--- via use-livecode
Hello Simon,
I see I probably misunderstood what you were trying to do. With a custom 
control I might be tempted to store the images in a customProp if I wanted 
multiple resolutions to travel with the group object. Then do something like 
setting the imageData of the image.
—
Scott

Elementary Software
(Now with 20% less chalk dust!)
web   http://elementarysoftware.com/
email sc...@elementarysoftware.com
booth 1-800-615-0867

> On Jul 24, 2018, at 8:44 AM, Simon Knight via use-livecode 
>  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.
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-24 Thread scott--- via use-livecode
Hello Simon,
When you say "compared to storing the images on a card or in a folder” it 
suggests two very different ways of organizing your source images. If you are 
taking advantage of LiveCode’s automagical ability to pick the correct 
resolution image then you need to have the images in your project be 
“referenced” controls. You can tell if they are referenced because when you 
examine them with the object inspector they will have a file path. (tip: the 
folder containing the images should be in the same folder as the mainStack of 
the project. Use the “Copy Files” tab in the Standalone Application Settings to 
attach it to your standalone. Also, in the object inspector, change the file 
path of the images to a relative paths. For example on Mac a file path might 
be: < /Users/yourname/someFolder/yourProjectFolder/images/myCustomButton.png > 
and you would change this to: < ./images/myCustomButton.png >

I store the images inside of LiveCode in different locations depending on the 
design of the app


Scott Morrow

Elementary Software
(Now with 20% less chalk dust!)
web   http://elementarysoftware.com/
email sc...@elementarysoftware.com
booth 1-800-615-0867

--

> On Jul 24, 2018, at 8:44 AM, Simon Knight via use-livecode 
>  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.
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Storing Images for use by Custom Controls

2018-07-24 Thread Bob Sneidar via use-livecode
Never mind I figured out why it wasn't working when I tested it. I was 
copy/pasting the custom control group into a stack on the desktop, but my 
images were relatively linked to png's in a subfolder in one of my project 
folders! LOL! 

It works fine. 

Bob S


> On Jul 24, 2018, at 09:43 , Bob Sneidar via use-livecode 
>  wrote:
> 
> Hmmm just tested. Doesn't seem to work. I'll have to investigate why. The old 
> script works though I pasted it numerous times. 
> 
> Bob S
> 
> 
>> On Jul 24, 2018, at 09:35 , Bob Sneidar via use-livecode 
>>  wrote:
>> 
>> No sooner said than done. Keep in mind this method depends on four things: 
>> 
>> 1. Your main group consists of a number of child groups composed of three 
>> controls: a button, an icon image and a disabledIcon image
>> 2. Your button names begin with "btn" and your images begin with "img" eg. 
>> "btnNew"
>> 3. Your "icon" images are named like your buttons, excluding the first three 
>> characters eg. "imgNew"
>> 4. Your "disabledIcon" images are named like your buttons, excluding the 
>> first three characters, and ending in "Disabled" eg. "imgNewDisabled"
>> 
>> 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
>>set the icon of button tButtonName to the short id of image 
>> tEnabledImage
>>set the disabledIcon of button tButtonName to the short id of image 
>> tDisabledImage
>> end repeat
>>  end repeat
>>  pass newBackground
>> end newBackground
>> 
>> 
>>> On Jul 24, 2018, at 09:14 , Bob Sneidar via use-livecode 
>>>  wrote:
>>> 
>>> 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 
  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.
>>> 
>>> 
>>> ___
>>> use-livecode mailing list
>>> use-livecode@lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your 
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



Re: Storing Images for use by Custom Controls

2018-07-24 Thread Bob Sneidar via use-livecode
Hmmm just tested. Doesn't seem to work. I'll have to investigate why. The old 
script works though I pasted it numerous times. 

Bob S


> On Jul 24, 2018, at 09:35 , Bob Sneidar via use-livecode 
>  wrote:
> 
> No sooner said than done. Keep in mind this method depends on four things: 
> 
> 1. Your main group consists of a number of child groups composed of three 
> controls: a button, an icon image and a disabledIcon image
> 2. Your button names begin with "btn" and your images begin with "img" eg. 
> "btnNew"
> 3. Your "icon" images are named like your buttons, excluding the first three 
> characters eg. "imgNew"
> 4. Your "disabledIcon" images are named like your buttons, excluding the 
> first three characters, and ending in "Disabled" eg. "imgNewDisabled"
> 
> 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
> set the icon of button tButtonName to the short id of image 
> tEnabledImage
> set the disabledIcon of button tButtonName to the short id of image 
> tDisabledImage
>  end repeat
>   end repeat
>   pass newBackground
> end newBackground
> 
> 
>> On Jul 24, 2018, at 09:14 , Bob Sneidar via use-livecode 
>>  wrote:
>> 
>> 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 
>>>  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.
>> 
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Storing Images for use by Custom Controls

2018-07-24 Thread Bob Sneidar via use-livecode
No sooner said than done. Keep in mind this method depends on four things: 

1. Your main group consists of a number of child groups composed of three 
controls: a button, an icon image and a disabledIcon image
2. Your button names begin with "btn" and your images begin with "img" eg. 
"btnNew"
3. Your "icon" images are named like your buttons, excluding the first three 
characters eg. "imgNew"
4. Your "disabledIcon" images are named like your buttons, excluding the first 
three characters, and ending in "Disabled" eg. "imgNewDisabled"

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
 set the icon of button tButtonName to the short id of image 
tEnabledImage
 set the disabledIcon of button tButtonName to the short id of image 
tDisabledImage
  end repeat
   end repeat
   pass newBackground
end newBackground
  

> On Jul 24, 2018, at 09:14 , Bob Sneidar via use-livecode 
>  wrote:
> 
> 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 
>>  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.
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Storing Images for use by Custom Controls

2018-07-24 Thread Bob Sneidar via use-livecode
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 
>  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.


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode