Need fast way to obtain vertical coordinates of text run

Richard Gaskin ambassador at fourthworld.com
Sat Nov 27 11:23:48 EST 2010


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: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  LiveCode Journal blog: http://LiveCodejournal.com/blog.irv




More information about the use-livecode mailing list