turning a list into something more complex

Devin Asay devin_asay at byu.edu
Wed May 31 11:07:48 EDT 2006


On May 31, 2006, at 8:04 AM, Rob Beynon wrote:

> And I say, being a pest(!)
> Devin, that is neat, and I shall play as soon as I am back at base  
> (away in conference). One problem I foresee is that the number of  
> lines is variable from run to run of the programme. Would you  
> create the scrolling list dynamically, or could I make a list of  
> say 200 lines, and hide the unneeded ones? If you had an example...:-)

Before I answer, let me just say that Chipp's suggestion (to use  
imbedded graphics in the field in conjunction with the popup command)  
might also be an excellent approach here. It would just depend on the  
types of controls that needed to be anchored to each line of text.

Okay, this is how I'd try appraoching it:

1. The field, and one of each type of control--say one checkbox and  
one option menu--are set up as templates and aligned to the first  
line of the field. Group these, turn on the group's vertical  
scrollbar, and lock the group's location. (set the lockLoc of group  
"mylistgrp" to true)

2. Populate the field with however many lines you need.

3. Use the formattedHeight property to set the physical height of the  
field:
    set the height of fld "mylist" to the formattedHeight of fld  
"myList"

    Keep in mind that the size and loc of the group needs to have  
been locked or the group will try to resize itself to accomodate the  
field's size.

4. Create a copy of the other controls for each line (line 2 to  
number of lines in fld "mylist"). Use the textHeight of the field to  
figure out how much space to leave between each control so that they  
line up with the proper line.

5. Update the hilite of the checkboxes and the contents of the option  
menus to match the contents of the corresponding line, as needed.

This is the basic recipe; the devil is in the details of getting it  
to create and align the needed controls properly. However, once it's  
working I've found it to be fast enough to handle several dozen  
lines--haven't needed to go higher than that so I don't know if there  
is an effective upper limit where it starts to bog down.

I hope this can get you to where you need to be.

Regards,
Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the Use-livecode mailing list