.net - How do I detect if both left and right buttons are pushed? -
I have three mouse actions on one control: left, right, and both.
I am left and right and currently using the middle button for the third, but I am curious how the left and right buttons can be pressed together, for those situations where the user Near the mouse without a middle button it will be controlled in the OnMouseDown method of custom control.
UPDATE After reviewing the suggested answers, I need to clarify what I was trying to do to click the mouse in the mouseDown event (actually OnMouseDown method of a control) Because it appears that .NET will always raise two mouse down events when both the left and right buttons are clicked on the mouse (one for each button), I guess the only way to do this To implement a delayed execution of some type of action after some low-level window messaging or mouse mode, either. Finally, this is the simplest way to use the middle mouse button.
Now, if action takes place on mouseup, suggestions of gary or node will work well.
Any other insights on this problem will be appreciated. Thanks!
There is always the "self-tax" approach:
Just remember to press the button On the Status and Release OnMouseDown, you just remember the button by pressing, and just check in OnMouseUp which buttons were missed, as well as clear the state for the button.
When you release the button, you should not make some arguments, such a
mouse button button is pressed; .. Zero OnMouseDown (MouseEventArgs e) {buttonPressed | = E. Button; } Zero OnMouseUp (MouseEventArgs E) {If ((Button pressed and mouse button pressed right mouse button button right and press and mouse button. Lift == mouse button) Press button & Mouse button .Medel == mousebutts. Middle) {Duminy Action (); DoneAction = true; } And if (check the correct button, etc) {....}} button pressed & amp; = ~ E. Button; If (button pressed == none) doneAction = false; }
Comments
Post a Comment