Calculate the number of rows in a scrolling field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Tony
Posts: 9
Joined: Sat Dec 15, 2012 8:52 pm

Calculate the number of rows in a scrolling field

Post by Tony » Mon Jun 05, 2017 7:08 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Calculate the number of rows in a scrolling field

Post by dunbarx » Mon Jun 05, 2017 7:38 pm

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

Tony
Posts: 9
Joined: Sat Dec 15, 2012 8:52 pm

Re: Calculate the number of rows in a scrolling field

Post by Tony » Mon Jun 05, 2017 8:16 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Calculate the number of rows in a scrolling field

Post by dunbarx » Mon Jun 05, 2017 9:00 pm

Good.

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

Craig

Post Reply