Need fast way to obtain vertical coordinates of text run

Jonathan Lynch jonathandlynch at
Sat Nov 27 12:31:17 EST 2010

Hi Richard,

I am pretty sure you can use the FormattedRect of a chunk of text to
accomplish this.

On Sat, Nov 27, 2010 at 11:23 AM, Richard Gaskin <ambassador at
> wrote:

> I need to know the vertical coordinates in pixels of the beginning and end
> points for a chunk of text in a scrolling field.
> I'm currently using the selectedLoc on the first and last char of the text
> run, locking the screen and messages while I get that.
> The problem is that I sometimes need to do this a thousand times in
> succession before I can return control to the user, and this causes
> significant delay.
> Because the text contains runs of variable height, I can't rely on line
> counts multiplied by the number of lines to the character in question.
> And because the text may contain Unicode, I can't rely on the formattedText
> for any of this either.
> And it seems that the formattedHeight works great for the full field, but
> cannot be used on chunks (I hope I misunderstand that, but I couldn't get
> any such syntax to work).
> And yes, the field resizes with the window, so I need to also recalculate
> on resizeStack as well.
> I briefly experimented with the mouseChunk, hoping that I could set and
> then restore the screenMouseLoc as needed, and while it sometimes works it
> really screws up the pointer interaction, no matter how cleverly I try to
> hide the cursor during that brief moment; and worse, the mouseChunk only
> returns a value when the mouse is actually over text, and sometimes blank
> lines may be there instead.
> I'm hoping there's some magically fast way to get those measurements
> without having to actually touch the field contents, which is apparently an
> inherently slow action (relatively speaking).
> Anyone here know of such magic?
> --
>  Richard Gaskin
>  Fourth World
>  LiveCode training and consulting:
>  Webzine for LiveCode developers:<>
>  LiveCode Journal blog:<>
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:

Do all things with love

More information about the use-livecode mailing list