Welcome to MSDN Blogs Sign in | Join | Help

The middle mouse button

Another input question that comes up a lot is what happened to the third mouse button?  We have MouseLeftButtonDown and MouseRightButtonDown events, but no MouseMiddleButtonDown event.  You can get at the middle button by using the attached event Mouse.MouseDown, which listens to all mouse buttons, and check for args.ChangedButton == MouseButton.Middle.

Okay, so that works, but why didn't we create a MouseMiddleButtonDown event like we did for the others?  Well, because we had to draw the line somewhere.  Some mice today support five buttons (left, middle, right, X1, X2), and at least one company I talk to wants even more.  And not all mice have three buttons, we wanted to make clear to application writers which buttons they can expect on all hardware, and which buttons may not be present.  We were also thinking beyond what we normally consider mice -- a tablet stylus generates mouse input (as well as stylus input), and can do left and right clicks but not middle clicks -- we thought that was a fair compromise for other future input devices as well.

The final possibility, of course, was not doing separate left vs. right events, and have only MouseDown.  We had that a long time ago, it's also what we did in Windows Forms, but we got strong feedback from the Windows User Experience folks about this.  Problem is, a single MouseDown event made it too easy for application authors to accidentally create applications that treat left and right buttons the same -- which is an  inconsistent and undesirable user experience.  And we want a platform where it's easy to do the right thing -- thus separate events for left and right.

Published Monday, June 13, 2005 8:41 PM by nkramer

Comments

Monday, June 13, 2005 9:10 PM by PatriotB

# re: The middle mouse button

Many right-click actions (e.g. displaying a context menu) shouldn't be in response to a right-click itself, but to the context menu action itself (WM_CONTEXTMENU in Win32 land)--that way it responds to the context menu key. I haven't looked into Avalon hardly at all, but does it support this distinction? It always annoys me when apps display menus on right-click but not in response to the context menu key.
Wednesday, June 15, 2005 6:32 PM by nkramer

# re: The middle mouse button

FrameworkElement.ContextMenuOpening is our equivalent of WM_CONTEXTMENU -- it gets raised when someone right clicks, presses the context menu key, or does a shift-F10. Most of the time, it's easier to just set the ContextMenu property and let Avalon do the rest, but ContextMenuOpening is for those times when you'd rather do it yourself.
New Comments to this post are disabled
 
Page view tracker