mouse event problem

C

Chuck Bowling

I have a problem I can't quite figure out. I want to trigger an event when
a some text is selected in a RichTextBox. When the selection is finished, I
want to mark the selected text and allow another selection. Text can be
selected two different ways; by double clicking a word or by clicking and
dragging. When I click and drag to paint the selection I mark it on the
MouseUp event. When double clicking, I catch the OnSelected event.

The problem is that double clicking causes the MouseUp event to fire. I
need to either disable the DoubleClick event in the text box or find a way
to fix the conflict between the two events. I would prefer to keep the
functionality of the double click event but if I have to I'll disable it.
Has anybody got a suggestion?
 
C

Chuck Bowling

No Carl. The problem is that the SelectionChanged event fires every time the
selection changes. So, if you drag over a word with say 5 characters,
SelectionChanged will fire 5 times. Not what I want.

I solved the problem by monitoring SelectionLength in the MouseUp event. If
the length is 0 then the MouseUp is probably due to the first click of a
DoubleClick event which is then ignored.

Thanks.
 

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