Mouse over text in richtextbox

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
 
S

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

This has always been a problem I don't think there is a good solution.
 
L

Lance Johnson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top