Find the scroll location in wrapped field

Michael Doub mikedoub at gmail.com
Tue Nov 18 16:25:05 EST 2014


Life is good when you have fixed line heights, dontwrap or listbehavior 
and you don't use spacebefore, spaceafter or imageSource

As you might expect, I live in opposite world: with multiple fonts, text 
sixes, spacebefore, spaceafter, word wrap and imageSource.   (I am 
trying to build a special purpose e-Book where the user can shrink and 
expand the text as needed with everything scaling, looking really nice 
with fluid page turning.)

pageranges, and formattedheight not working are forcing me to work a lot 
harder than I would like, because I am not willing to compromise on how 
it looks.

-= Mike



On 11/18/14 2:37 PM, J. Landman Gay wrote:
> On 11/18/2014, 1:08 PM, dunbarx at aol.com wrote:
>> I tried a bunch of stuff like that; your thinking seems sound. I
>> thought mine did as well.  Sometimes it sets a line properly, and
>> sometimes, especially  with small textSize lines near large ones, not
>> at all. In fact, several lines away.
>
>
> I am still not having any issues at all with this handler:
>
> on doScroll pNum
>   put the formattedheight of line 1 to pNum of fld 1 into tScroll
>   set the scroll of fld 1 to tScroll
>   set the hilitedline of fld 1 to pNum
> end doScroll
>
> It places the correct line at the top, no matter which line is 
> currently selected, and selects the designated line of the field.
>
> The thing that makes this work is that it does require having 
> listbehavior set to true. Once that's done, the engine handles all the 
> details without any trouble.
>
> Here is the handler I used to set up the field content. I add the line 
> numbers so I can see whether the correct line does in fact get selected.
>
> on setup
>   get the colornames
>   repeat with x = 1 to the number of lines in it
>     put x & space before line x of it
>   end repeat
>   put it into fld 1
>   repeat with x = 1 to the number of lines in fld 1 step 2
>     set the textsize of line x of fld 1 to random(40)+12
>   end repeat
> end setup
>
>





More information about the use-livecode mailing list