I would like have three mouse actions over a control: left, right and BOTH.
I’ve got the left and right and am currently using the middle button for the third, but am curious how I could use the left and right buttons being pressed together, for those situations where the user has a mouse without a middle button. This would be handled in the OnMouseDown method of a custom control.
UPDATE
After reviewing the suggested answers, I need to clarify that what I was attempting to do was to take action on the mouse click in the MouseDown event (actually OnMouseDown method of a control). Because it appears that .NET will always raise two MouseDown events when both the left and right buttons on the mouse are clicked (one for each button), I’m guessing the only way to do this would be either do some low level windows message management or to implement some sort of delayed execution of an action after MouseDown. In the end, it is just way simpler to use the middle mouse button.
Now, if the action took place on MouseUp, then Gary’s or nos’s suggestions would work well.
Any further insights on this problem would be appreciated. Thanks!
Based on what I learned from the other answers, I was able to get this working. I post the solution here in case some else needs it.
I created a component, MouseDownManager, that I call during the MouseDown event. It tracks the button just pushed, determines what button we are waiting for in order to have a “both” buttons down event, then starts a timer to wait for that button. If within the allotted time, the correct button is pressed, the MouseDownManager raises the appropriate “both” button down event. Otherwise it raises the appropriate single button event. On the form, I’m handling the MouseDownManager’s MouseDown event to take action on the translated mouse click.
I can now just drop this component on a form/control and I can react to a “both” click.
Thanks for the help in figuring this out.