Scrolling to a clicked line when dontwrap=false

Peter M. Brigham, MD pmbrig at
Sat Aug 27 08:07:26 EDT 2011

On Aug 27, 2011, at 5:11 AM, Tim Selander wrote:

> I have a field full of (locked) text (a TV script), lines are wrapped. I want to be able to click a word in the text and automatically set the scroll of the field so that the line with the clicked word is at the very top of the field.
> I can set the vscroll of the field using the number returned by (the clickline)*(the textheight) of the field. But, each wrapped line in the text above the click throws that calculation off...
> How can I take the wrapped lines into consideration so that the text my users click pops to the top of the field?

Something like this, maybe (untested)

on mouseup
   put word 2 of of the clickCharChunk into chNbr
   put the number of words of char 1 to chNbr of me \
           into wordNbr
   put the formattedheight of word 1 to wordNbr of me \
           into upToHere
   put the textheight of me into txtHt
   set the scroll of me to upToHere - txtHt
   -- so the line remains visible
end mouseup

-- Peter

Peter M. Brigham
pmbrig at

More information about the Use-livecode mailing list