selecting text

lowee (starnet!apple!cpsc.ucalgary.ca!lowee)
Thu, 10 Jun 93 12:52:57 -0600

I would like to be able to implement highlighting, i.e have users
select text, then highlight it. I don't just want to change the
foreground colour, but the background as well, (or maybe just the
background, like real highlighting)

The problem is I can't think of any easy/good way to do this. One
possiblity is to draw a filled polygon behind the selected words.
This would be a decent solution, but I can't find the boundaries of the
selected text. The function selectedLoc gives the upper left, but I
don't know where the selection ends. Furthermore, selecting more than
one line could be troublesome.

One (really, really, really ugly) solution to find where the selection
ends is to copy the selected text into an invisible field and get the
formattedWidth and formattedHeight of that field. This works, but only
if the selection consists of words on the same line.

Ideally, I would like to be able to add a text style, and just set a
highlighted property for the selectedText.

Anybody got any good ideas??

-Earle

lowee@cpsc.ucalgary.ca
Pseudomember of the University Of Calgary GraphicsJungle