Mouse over text in richtextbox

  • Thread starter Thread starter Lance Johnson
  • Start date Start date
L

Lance Johnson

I can't seem to find out if the mouse cursor is over text in a richtextbox.
I can use GetCharIndexFromPosition but all that does is tell me the closest
character. But if the cursor is outside the range of current text, there's
no way to calculate that. I'm sure there should be something to tell me how
to do this, but I can't seem to find it.

Lance Johnson
 
This has always been a problem I don't think there is a good solution.
 
Well crap. Basically what I did was calculate where the character after the
end of text would appear and if the mouse is on that x position or after,
then it's not over the selected text. This works great for single line
stuff, but obviously can have issues on multi-line stuff if that next
character wraps to the next line. I'm sure I could come up with some kind
of logic to determine that, but I haven't yet because so far we've just been
worried about single-line richtextboxes.

Lance Johnson


Stoitcho Goutsev (100) said:
This has always been a problem I don't think there is a good solution.


--
Stoitcho Goutsev (100) [C# MVP]

Lance Johnson said:
I can't seem to find out if the mouse cursor is over text in a
richtextbox. I can use GetCharIndexFromPosition but all that does is tell
me the closest character. But if the cursor is outside the range of
current text, there's no way to calculate that. I'm sure there should be
something to tell me how to do this, but I can't seem to find it.

Lance Johnson
 
Back
Top