Scrolling to a clicked line when dontwrap=false

Tim Selander selander at tkf.att.ne.jp
Sat Aug 27 11:19:39 EDT 2011


That worked extremely well -- thank you! Very clever use of the 
formattedheight.

Tim Selander
Tokyo, Japan

On 8/27/11 9:25 PM, Peter M. Brigham, MD wrote:
> 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?
>
> Just tested it: two revisions. If the textheight of the field is empty then the original handler won't work, so use "the effective textheight of me." Also, correct for the borderwidth of the field:
>
> 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 effective textheight of me into txtHt
>     put upToHere - txtHt + (the effective borderwidth of me) \
>            into upToHere
>     set the scroll of me to upToHere
>     -- so the line remains visible
> end mouseup
>
> -- Peter
>
> Peter M. Brigham
> pmbrig at gmail.com
> http://home.comcast.net/~pmbrig
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>




More information about the use-livecode mailing list