listField - dontWrap

Signe Marie Sanne Signe.Sanne at roman.uib.no
Tue Jun 14 05:24:06 EDT 2005


Signe Marie Sanne skrev:

> Hello,
> I have a number of phrases, each delimited by return in a scrolling 
> field. When the user clicks anyone of these, the line should be 
> highlighted in some way.
> 
> The problem is that some of the phrases are longer than the field width, 
> if I use list field behaviour the longest phrases are just cut off. I 
> searched the archives and found two scripts for "formatFld", but none of 
> them worked for me.
> 
> I then tried to calculate the distance from the top of the field and 
> placed a gray graphic underneath, but this solution will not work when 
> the user scrolls the field. Grateful for suggestions.

I answer myself: I found the solution. It's funny, that's the rewarding 
thing about scripting, you have a problem, you try and retry, and when you 
finally find the solution you really feel fine!

So here it goes:
You have two identical fields (F1 and F2), both are ordinary scrolling 
fields with dontwrap set to false and listbehavior set to false.

- In field F1 you display the phrases. Copy the text of fld F1 to fld F2.
- set the layer of the copied field lower than the layer of field F1 (that 
is, you put fld F2 under fld F1)
- set the textcolor of char 1 to -1 of fld F2 to white - which is the colour 
of the background (in this way the text is invisible)
- move fld F2 a little to the left (0,5 cm or so)
- group the two fields. In the group script put:
            on scrollbardrag
               set the scroll of fld F2 to the scroll of fld F1
            end scrollbardrag

- in the script of fld F1 you put:
  	put word 2 of the clickLine into snr
    	set textcolor of char 1 to -1 of fld F2 to white (deletes the previous 
bullet)
   	put "ユ" into char 1 of line snr of fld F2 (this is the bullet 
equivalent, it is not displayed correctly in this email)
   	set textcolor of char 1 of line snr of fld F2 to 255,102,102

I'll upload a stack to show this within a few hours.
Signe Marie

signe.sanne at roman.uib.no   http://www.hf.uib.no/mlab/Info/sms.html


More information about the use-livecode mailing list