fixed textheight affects scrolling?
klaus at major-k.de
Thu Jul 9 07:34:08 EDT 2020
> Am 09.07.2020 um 11:40 schrieb Klaus major-k via use-livecode <use-livecode at lists.runrev.com>:
> Hi Mark,
>>>> Hi friends,
>>>> strange phenomenon, maybe I am missing something!?
>>>> LC 9.6 on macOS 10.14.6
>>>> I have two fields with all available fonts and each line is formatted directly
>>>> in the appropriate font it reads.
>>>> I set the FixedLineHeight for ONE field to 28, doesn't matter actually.
>>>> Now I want to select a specific line in the fields with this script:
>>>> on mouseUp pMouseButton
>>>> set the wholematches to TRUE
>>>> put lineoffset("Lucida Grande",fld "fonts") into tLine
>>>> ## Which is 366 in my fields!
>>>> put the effective textheight of fld "fonts" into tTH
>>>> set the scroll of fld "fonts" to tLine*tTH + the height of fld "fonts"
>>>> set the hilitedlines of fld "fonts" to tLine
>>>> end mouseUp
>>>> Works fine for the field WITHOUT fixedlineheigt and selects the line -> Lucida Grande
>>>> However the same script used with the field WITH fixedlineheight, it selects -> Lucida Grande Bold
>>>> which is the line AFTER "Lucida Grande" and actually line 367!?
>>>> What am I overlooking?
>>>> Thanks for any hints!
>> I suspect the fact it works in the non-fixedline height case is serendipity in this specific case - if line height isn't fixed then each line will have a different height based on the fonts (although most will be the same if the fontSize is the same)...
>> LineOffset is 1-based - so the first line has scroll 0ish (ish because of field margins etc.) - that's probably the issue with your existing code.
>> There's an easier way I think though which should be independent of any field styling (size, font, wrapping)...
>> You can get the formattedTop of a line - which gives you the card-relative y co-ordinate of the top of the including the fields top and scroll. So this should do the trick:
>> set the scroll of field "fonts" to the scroll of field "fonts" + \
>> the formattedTop of line tLine of field "fonts" - \
>> the top of field "fonts"
>> The adjustment is necessary because the scroll value is relative to the top-left of the 'content' of the field.
>> Hope this helps!
> thank you very much!
> But even with this new script LC scrolls to and selects -> Lucida Grande only if "fixedlineheight" is UNchecked!?
I removed the formatting of the "fonts" field, set all lines to "Arial" and now everything (my original script and Marks script)
works as advertized even WITH "fixedlineheight" checked!?
So I think these many different fonts in a field are somehow "puzzling "LC (and me :-).
Or maybe not, I have no idea...
klaus at major-k.de
More information about the use-livecode