views:

131

answers:

1

I'm working with a RichTextBox, and would like to do one thing in the SelectionChanged event if the mouse is down, and another if it's not (e.g. if the keyboard is used to select something). However, the SelectionChanged event is apparently called before MouseDown, so it seems there's no way for me to know if the mouse is down while processing the SelectionChanged. Has anyone else run into this problem? Does anyone have a solution that worked for them?

I'm doing some highlighting code, and I need to have the mouse intercepted before SelectionChanged is called.

A: 

You could save the selection in a variable and work with it in the MouseDown handler. It would give you pretty much the same behaviour.

kek444
I also need to handle non-mouse selections, so unfortunately I'm not sure that would work. Thanks, though.
NickAldwin
Then simply add checking in KeyDown etc. events. You won't get this done much prettier that that.
kek444
True. I'll see how it works.
NickAldwin