Screen coords for a glyph?

Dan Ingalls Dan at SqueakLand.org
Sat Dec 1 17:26:45 UTC 2001


"Michael Cole"@bestweb.net, broccole at panix.com  wrote...

>Is there a clever way of learning the position of a specific glyph in a
>text morph? I'm trying to anchor morphs to specific sections of text and
>cannot see a means of determining the coordinates apart from
>recalculating the layout of the text from StrikeFont.
>
>If there isn't already a built-in method, is it possible to send a
>handmorph to an offset in a text (and then have it report its position)?

I'm about to run out the door, but two imporatnt methods are
	NewParagraph>>characterBlockAtPoint:, and
	NewParagraph>>characterBlockforIndex:.
A characterBlock gives you the rectangle of the glyph, and also its string index in the text.  To get the proper recipient, send these messages to, eg,
	myTextMorph paragraph.

Also read the class comment of TextAnchor.  I think Squeak already does what you want.

Hope this helps.

	- Dan




More information about the Squeak-dev mailing list