Working in IT, I occasionally encounter users who are left-handed and prefer to use the mouse with their left hand, and often they switch the mouse buttons so the right button becomes the "primary" instead of the left button.
Here's what this configuration looks like in Windows:
How does this affect .NET applications (e.g. WPF, Winforms, etc.) which have code that relies on specific mouse buttons?
With the WPF PreviewMouseDown event, for example, MouseButtonEventArgs has a ChangedButton property which yields a MouseButton enum value. The description for Left is "The left mouse button." There is nothing said about "primary" or "secondary" buttons.
Similarly for the Winforms MouseClick event, there is MouseEventArgs with its Button property yielding a MouseButtons enum; the description for Left is simply "The left mouse button was pressed.", and again there is no mention of "standard" or "secondary" buttons.
In fact, all of the documentation I've seen related to the mouse and its buttons simply refer to the buttons by their location on a standard mouse setup. None of the documentation refers to "primary" or "secondary" mouse buttons.
Does the .NET framework adapt appropriately to changes in the OS' button configuration? Or will the following WPF and Winforms code break?
WPF:
void MainWindow_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
{
// do something where the "standard" mouse
// button must be the one that was clicked.
}
}
Winforms:
private void MainForm_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
// do something where the "standard" mouse
// button must be the one that was clicked.
}
}


