Custom "Widget" Technique Question

Richard Gaskin ambassador at fourthworld.com
Sat Sep 12 15:49:15 EDT 2009


Len, this sounds really cool:

> I'm working on a new project and I'd like some advice on how to create 
> custom controls to use on a graphical process display.  This will 
> display a water pipeline system with all it's tanks, pipe, valves, 
> flow/pressure meters etc.  One of the items I have to display is a water 
> tank and I need to display how much water is in it as both a number and 
> a graphical representation of the water level.  I've got the gist of the 
> drawing managed but I'm going to have to have several of these and I 
> don't want to hand create them every time so I'm looking to make a 
> "water tank" custom control.
> 
> I need to put it somewhere, send it a current level which would update 
> the numeric display and set the "water" level.  I'd also like to size 
> them so I could have big ones and small ones.
> 
> That's a long introduction to my actual question.  I know I can make a 
> group of the various parts and script the updating and possibly sizing 
> using behavior scripts but once I've created it, where to I put it?  Do 
> I create a stack with this group on it and then clone it where I need 
> it?  Do I copy and paste (via script)?  I can't add it to the Rev 
> graphic object pallet like the datagrid is now.
> 
> This is not the only custom control I'm going to need so I'm looking for 
> a generic way to handle this kind of thing.  In the end, the program 
> will not only have a display of our pipeline but I'd also like to have a 
> separate design program to create the system diagrams in case any other 
> pipelines want to use the program.

Check out the new Behaviors in v3.5.  This will let you use a button 
script that you could put anywhere (I tend to put mine in a library or a 
substack, depending on whether I plan to reuse them in other apps or 
not), and then assign the behavior of your template group to that button 
script.  From then on it's really easy, since all your code is in one place.

Using getProp and setProp you can adjust any number of things within the 
group from a single property setting.

And if you use v3.5's new selectGroupedControls property for groups, you 
can keep your layout work clean since the pointer tool will treat the 
group as a single object, regardless of the setting of the global 
property of the same name.

Use "copy <grpDescriptor> to <destinationStackDescriptor>" to add copies 
of groups to your layout.

Keep us posted on how this goes.  I love simulations, and would love to 
see what you come up with.

--
  Richard Gaskin
  Fourth World
  Revolution training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com



More information about the use-livecode mailing list