Design philosophy of a Custom Control.
Posted: Tue May 21, 2019 9:27 am
I recognise that this is risky post as I'm asking for opinions but here goes......
I am in the process of completing a custom control that displays a list of thumbnail images. I created it with a specific task in mind but think it may be useful in other projects. Others may also find it useful but I want to ensure that it complies with the accepted norms of Livecode Custom Controls before I am brave enough to offer it up for inspection.
My custom control is named PhotoViewer it displays a list of sub groups that I have named polaroids : As I hope you can see each polaroid is a group comprising an image and some fields. At present all the code that is required is stored in two behavior buttons that are placed on a sub-stack named after the control e.g. stack "photoviewerBehaviors". I adopted this structure based on a talk that Ken Ray gave back in 2011 where he recommends keeping the code of the custom control away from any code that the user might want to add. Is this still a reasonable approach?
The alternative is to place the code inside the two group scripts which would mean that the code in the polaroid is duplicated for every polaroid created. Doing it this way would mean that Photoviewer is self contained but I am concerned that the duplication of the code that each polaroid uses may cause problems when large numbers of polaroids are created.
Your thoughts are welcome.
P.S. has anyone a handle on how groups really function. I found populating a group using code a bit of a nightmare and the documentation pretty poor i.e. what are the interactions between BoundingRect, ClipsToRect and LockLoc?
best wishes
Simon
I am in the process of completing a custom control that displays a list of thumbnail images. I created it with a specific task in mind but think it may be useful in other projects. Others may also find it useful but I want to ensure that it complies with the accepted norms of Livecode Custom Controls before I am brave enough to offer it up for inspection.
My custom control is named PhotoViewer it displays a list of sub groups that I have named polaroids : As I hope you can see each polaroid is a group comprising an image and some fields. At present all the code that is required is stored in two behavior buttons that are placed on a sub-stack named after the control e.g. stack "photoviewerBehaviors". I adopted this structure based on a talk that Ken Ray gave back in 2011 where he recommends keeping the code of the custom control away from any code that the user might want to add. Is this still a reasonable approach?
The alternative is to place the code inside the two group scripts which would mean that the code in the polaroid is duplicated for every polaroid created. Doing it this way would mean that Photoviewer is self contained but I am concerned that the duplication of the code that each polaroid uses may cause problems when large numbers of polaroids are created.
Your thoughts are welcome.
P.S. has anyone a handle on how groups really function. I found populating a group using code a bit of a nightmare and the documentation pretty poor i.e. what are the interactions between BoundingRect, ClipsToRect and LockLoc?
best wishes
Simon