I knew you could select the line number, but I did not know starting at the end 
would provide the best results. This will be helpful, thanks.

One method I have used in the past is to put the htmlText of the field into a 
variable, then put line 1 to (the line to scroll to) into the field (or delete 
line (scroll line +1) to -1 of the field. Find the formattedHeight at this 
point, set the htmlText of the field back to the original contents, then scroll 
to the formattedHeight value.

- eric


On Nov 18, 2014, at 7:14 AM, Richard Gaskin <ambassa...@fourthworld.com> wrote:

> dunbarx wrote:
> >> James Hale wrote:
> >>
> >> So if you have the linenumber of the line contains the text you wish
> >> to see at the top of the field then...
> >>
> >>    select line  -1 of  field "TextToScroll"
> >>    select line linenumber of  field "TextToScroll"
> >>
> >> And line linenumber will now be at the top of the field.
> >
> >
> > The field will scroll to the desired line, but if the textSizes
> > of those lines are variable, the scroll will not come out right.
> >
> >
> > The discussion here and on the forum is how to make that happen.
> > So far, no solution. The OP wanted to find text, and this is
> > straightforward, in that the foundline can be used to set the
> > line selection. But his data was with mixed textSizes, and that
> > is how this all started.
> 
> If James were suggesting doing calculations based on textHeight you'd be 
> spot-on, but by using selection he's relying on the engine's understanding of 
> the text as rendered - testing here it seems to work quite well.
> 
> If we needed to do this with calculations only (if for some reason selection 
> would be problematic), we could use the formattedHeight of line 1 to the 
> desired line, subtracting the effective textheight of the desired line itself 
> (and accounting for the topmargin), e.g.:
> 
>   put lineoffset("stringWeAreLookingFor", fld 1) into tLOS
>   put the effective textheight of line tLOS of fld 1 into tHt
>   put the formattedHeight of line 1 to tLOS of fld 1 into tScroll
>   set the vscroll of fld 1 to (tScroll-tHt-the topmargin of fld 1)
> 
> -- 
> Richard Gaskin
> Fourth World Systems
> Software Design and Development for the Desktop, Mobile, and the Web
> ____________________________________________________________________
> ambassa...@fourthworld.com                http://www.FourthWorld.com
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to