[Q] TextMorph, MouseMoveEvent and detecting a word
Steve Swerling
sps2000 at mail.com
Mon Jan 21 19:27:12 UTC 2002
> So my question is how to find out a word in a TextMorph given a point in
> it. Could somebody help me please?
A method worth viewing is ParagraphEditor>>selectWord. You might try
making a copy of that method, and then alter the copy so that it returns
an Interval in all the places where it currenlty selects a range of
characters. You would also have to chane the way that method determines
the starting string index. Where #selectWord uses the startBlock, you
would use (as Ned said) the paragraph's #characterBlockAtPoint: method
to get the CharacterBlock, then ask for its #stringIndex.
(The ParagraphEditor can is accessable from the PluggableTextMorph by
calling "textMorph editor", the Paragraph is accessible from "textMorph
paragraph").
Hannes Hirzel wrote:
>
> Hi
>
> I'd like to know over which word the mouse is in the text of a TextMorph.
> The message
> handleMouseMove: anEvent
> is sent to the TextMorph, where anEvent is a MouseMoveEvent. It has the
> instance variable 'position' which is a Point.
>
> So my question is how to find out a word in a TextMorph given a point in
> it. Could somebody help me please?
>
> Regards
> Hannes
More information about the Squeak-dev
mailing list
|