Page 1 of 1

Calculate the number of rows in a scrolling field

Posted: Mon Jun 05, 2017 7:08 pm
by Tony
Is there a way to calculate the total number of rows a body of text takes up in a field? Or perhaps the total "height," in pixels, of all of the text in a scrolling field?

I'm trying to mimic the typewriter-scrolling effect used in some writing apps (such as Scrivener) that keeps the cursor in the middle row of the field as you type.

Thanks.

Tony

Re: Calculate the number of rows in a scrolling field

Posted: Mon Jun 05, 2017 7:38 pm
by dunbarx
Yes.

Do any of these help: the "textHeightSum". the "textHieght". the number of lines of fld "yourField", the "formattedText"

Also. the "effective" keyword.

Also watch out for fields with dontWrap set to "true". This is where the formattedText is invaluable

With these and other tools, you can set the selection to a chunk expression as needed.

Check the dictionary for all of these terms, and practice a bit.

Craig Newman

Re: Calculate the number of rows in a scrolling field

Posted: Mon Jun 05, 2017 8:16 pm
by Tony
dunbarx wrote:Do any of these help: the "textHeightSum". the "textHieght". the number of lines of fld "yourField", the "formattedText"

Also. the "effective" keyword.

Also watch out for fields with dontWrap set to "true". This is where the formattedText is invaluable

With these and other tools, you can set the selection to a chunk expression as needed.

Check the dictionary for all of these terms, and practice a bit.
Yes, that's a great starting point for me. (Well, after a few hours of going nowhere, fast...) Thanks!

Tony

Re: Calculate the number of rows in a scrolling field

Posted: Mon Jun 05, 2017 9:00 pm
by dunbarx
Good.

Also check out the "selectedLine", and, for that matter, all dictionary entries that begin with "selected".

Craig