Custom Control Design Tutorial

Len Morgan len-morgan at crcom.net
Sat Mar 27 10:32:23 EDT 2010


Maybe *I'm* the one that's misinterpreted the question! :-)  I think 
what you're telling me is that I'm over engineering the problem and that 
all I'm really after is a self-contained group that has all of the 
functions I'd need to manipulate the tank which I would then copy (or 
clone?) as many times as I needed to get the required number of tanks.  
I guess in the end, a Data Grid is nothing more than a group.

This actually brings up another question though: There are some cases of 
tanks in the current system that display the feet of water in the tank 
next to the tank, and some where the number is shown IN the tank.  If we 
temporarily ignore how I'd let the user move around the component parts 
of a tank (assuming I'd let them), what are the "locations" of the 
components in the group (i.e., oval and rectangle for water graphic, 
text box for numeric level, etc) telling me?  Are they the physical 
locations on the screen at that instant or are they (or can they be) 
relative to the location of the group as a whole?

len morgan

On 3/27/2010 9:18 AM, Björnke von Gierke wrote:
> I'm not sure what would make your "object" not be portable?
>
> the main things to look out for are:
>
> Changing the rectangle or location will of course change some movement dependant scripts. you need to look out for that if you do graphical stuff (like resizing a water level graphic for your tank).
>
> Use a group, and set its lockLoc to true. Generally It's easier to handle various objects that belong together if they're grouped.
>
> Keep your scripts together.  Group all objects that belong to your "custom" object, and move all "toplevel" scripts into that group's script.
>
> Try to keep all custom properties in that group too, so that you have one place to go to for setting stuff and calling scripts.
>
> To be able to identify the correct "object" when there's several on one card, I suggest to change the groups name to something unique.
>
> Beyond that, there's really no additional measure to take, unless I misinterpreted your question.
>
> On 27 Mar 2010, at 14:32, Len Morgan wrote:
>
>    
>> Has anyone created a tutorial for creating and using a custom control?  What I'd like to end up with is a custom control that I could copy onto a stack similar to Trevor's Data Grid.  As an example, I've been tasked with redesigning the GUI for a pipeline control system that comprises various tanks, pumps, valves, etc. and I'd like to just create one of each and be able to put multiple instances on a "page" (the system currently uses 6 HUGE monitors hung on the wall of the control room).
>>
>> To the a "water tank" as an example, it needs the following:
>>
>> It needs to look like a water tank (cylinder of varying hieght) with "water" in it that goes up and down to reflect the amount of water that is actually in the tank.
>>
>> A number to show the current level (in feet) that is in the tank.
>> Some parameters like tank height, spill height, minimum level with an alarm if the level goes below it.
>> A visual indication that it is spilling or has gotten too low.
>>
>> I created a little stack and I can do this graphically and I can set variables like currentTankLevel and have it change the number and the "water level" but it's not "portable" so I guess what I'm asking is if there is a tutorial that can tell me how to take this one-off widget I've created and turn it into a custom control/widget that I could copy on to a stack and then "set up" to make that instance unique?
>>
>> I know it will probably need behavior scripts and such, and I'm pretty sure all the pieces to do this are laying around in the mail archives somewhere but I was hoping that there was some sort of a step by step guide.
>>
>> Any pointers would be welcome.
>>
>> len morgan
>>      
>
>
>    




More information about the use-livecode mailing list