c# - When the mouse buttons are swapped in the OS, do the mouse click event handlers still work correctly with respect to which button was clicked? -


working in it, encounter users left-handed , prefer use mouse left hand, , switch mouse buttons right button becomes "primary" instead of left button.

here's configuration looks in windows:

enter image description here

how affect .net applications (e.g. wpf, winforms, etc.) have code relies on specific mouse buttons?

with wpf previewmousedown event, example, mousebuttoneventargs has changedbutton property yields mousebutton enum value. description left "the left mouse button." there nothing said "primary" or "secondary" buttons.

similarly winforms mouseclick event, there mouseeventargs button property yielding mousebuttons enum; description left "the left mouse button pressed.", , again there no mention of "standard" or "secondary" buttons.

in fact, of documentation i've seen related mouse , buttons refer buttons location on standard mouse setup. none of documentation refers "primary" or "secondary" mouse buttons.

does .net framework adapt appropriately changes in os' button configuration? or following wpf , winforms code break?

wpf:

void mainwindow_previewmousedown(object sender, mousebuttoneventargs e) {     if (e.changedbutton == mousebutton.left)     {         // "standard" mouse          // button must 1 clicked.     } } 

winforms:

private void mainform_mouseclick(object sender, mouseeventargs e) {     if (e.button == system.windows.forms.mousebuttons.left)     {         // "standard" mouse          // button must 1 clicked.     } } 

by running couple tests, i've determined .net is smart enough recognize buttons have been swapped.

for instance, in both of following tests wpf , winforms, after switching mouse buttons in windows, clicked physical "right" mouse button, the event responded indicating "left" mouse button used:

wpf:

enter image description here

winforms:

enter image description here

therefore, despite lack of documentation microsoft, left refers "standard" mouse button , right refers "secondary" mouse button.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -