Date: | April 13, 2009 / year-entry #108 |
Tags: | other |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20090413-00/?p=18573 |
Comments: | 21 |
Summary: | Commenter Nekto2 asks why there is no mouse action associated with "click both buttons at the same time". The window manager doesn't fire a special event for both mouse buttons held down simultaneously like it does for double-clicks. As with higher-order clicks, mouse chording is something that you have to put together yourself from the... |
Commenter Nekto2 asks why there is no mouse action associated with "click both buttons at the same time". The window manager doesn't fire a special event for both mouse buttons held down simultaneously like it does for double-clicks. As with higher-order clicks, mouse chording is something that you have to put together yourself from the basic mouse events that the window manager generates. Add these lines to our scratch program: void OnButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) { if ((keyFlags & (MK_LBUTTON | MK_RBUTTON)) == (MK_LBUTTON | MK_RBUTTON)) { MessageBeep(IDOK); } } // Add to WndProc HANDLE_MSG(hwnd, WM_LBUTTONDOWN, OnButtonDown); HANDLE_MSG(hwnd, WM_RBUTTONDOWN, OnButtonDown); When you run this program, it beeps when both the left and right mouse buttons are pressed. Note that the program does not require the two button presses take place simultaneously. Most people do not have the dexterity to push the two buttons at precisely the same instant in time. (Especially since Einstein taught us that simultaneity is relative anyway.) Why don't more programs use chording? Recall that the semantics of double-clicking should be an extension of the single-click so that your program can perform the single-click action immediately (providing positive feedback to the user that the click was recognized), and then continue to the double-click action if a second click comes in. For example, a common pattern is for the single-click to select the clicked-on item and the double-click to launch it. You can stop at the first click and the result still makes sense. For chords, you have to have two stopping points, one if the user left-clicks and stops, and another if the user right-clicks and stops. Coming up with a chord action that is compatible with both stopping points requires more effort. Another reason why many people choose to avoid chords in their user interface design is that chording requires more dexterity, and many users simply don't have the fine motor control necessary to pull it off without accidentally invoking some other action (such as a drag). Chording is also cumbersome to emulate with MouseKeys, so you run afoul of accessibility issues. Still, there's nothing technically preventing you from using chording in your program. If you want to code it up, then more power to you. |
Comments (21)
Comments are closed. |
The only place where I found the two-button click useful was in X with a two button mouse to emulate the middle click. And I still think that context menus are a much better way of doing it.
On the other hand, flipping (i. e. hold one button, click second, release first) rocks.
I believe that Mac OS X and Linux have a feature that you can enable (it’s off by default) where clicking both mice button at once simulates a middle-click, in case the user doesn’t have a 3-button mouse. Of course, I’m sure many programs don’t anticipate this, so if they use the middle mouse button, they probably behave somewhat unexpectedly if the user has a noticeable delay between pressing one mouse button and pressing the other.
If a program used both the middle mouse button and left+right chords (with different functions), then I guess users without a 3-button mouse would be out of luck in either case. I would argue, though, that suck programs are not well-designed.
Then what, exactly, does the * key do in MouseKeys? It shades both buttons on the notification icon, which to me says that it will click both buttons at the same time. If that’s supposed to be the middle button, it needs to be re-worked so it has three buttons in the icon.
the reply is right on the money.
Some 3D modeling apps do support two-buttons gestures to do some things (usually zooming related)
But even more 2D application (like photo editing) support pressing two keyboard keys like shift+ctrl during interaction.
it’s all the same really.
If you’re in the 1% of apps with non-trivial mouse interaction, all you use is the button up/down key up/down. I wonder what the OS could do better.
@Adam Rosenfield
This works reasonably well. The delay between the two button presses is adjustable (80ms by default IIRC), so both two-button clicking and flipping work. BTDT.
If an X program does indeed require a two-button click, the programmers should of course be tarred, feathered and forced to use a Mac boot camped with MS-DOS.
@Adam Rosenfield: Windows 98 had that!
I can’t be the only one who thought of Minesweeper when reading this, right? In my mind, it’s the perfect application of this concept — chording in Minesweeper provides no functionality that isn’t available with a single left mouse click, but helps power users a lot.
"But even more 2D application (like photo editing) support pressing two keyboard keys like shift+ctrl during interaction."
That’s different, though, because the Ctrl key doesn’t have a meaning on it’s own and you can’t press A then CTRL and get the same behaviour as CTRL then A. Also, the keyboard doesn’t move around so the dexterity requirements are lower (you can also use two hands if you really need to)
Well, isn’t it obvious? The OS and its APIs should account for all past, present and future needs of users/applications/developers from day one, and nothing less is acceptable! How dare they force people to implement features on their own??? :-p
Richie – good point, I can’t believe I didn’t think of Minesweeper! However, it did remind me of games like Street Fighter and Mortal Kombat, with all the "special move" stick/button combos.
One option is right cancels left. So e.g. you begin some action by clicking the left button, and then you drag and release. But if during the drag you realise that you didn’t want to do this at all then rather than complete the action, and undo it, you can right click before releasing left to cancel the whole thing immediately. I’ve seen this in a few applications.
This isn’t quite like chording as most people think of it, but it overlaps in terms of method of input and programming approach.
In Linux and other PC-based *nix, the middle button may be absent, yet the X protocol specified that pressing middle pastes whatever highlighted text is present. Thus middle click is esstential.
In MacOS, the design philosophy is to make everything accessible via a "left" click, because you may have only one mouse button. Thus developers are encouraged to consider how someone may do an action with just one mouse button. Then they can consider right-click as a shortcut to do that action. (It infuriates me to no end when I find that to do something, I have to right-click in a specific spot, and there’s no obvious workaround in the menus or keyboard shortcuts. Right-clicking shouldn’t hide new functionality, but make life easier…)
Sorry if this has been answered, but why do you link to your 2003 Scratch program and not the 2005 updated one?
Worf, the X protocol specifies nothing about the meaning of button clicks.
The use of middle button to paste the current selection is just an application convention, and it’s not "essential" since you can of course just use the clipboard, as follows:
• select text
• middle click paste current selection
becomes
• select text
• copy (typically Ctrl-C or menu)
• paste (typically Ctrl-V or menu again)
Hopefully they will have support for advanced chording in the Surface API, otherwise the Composer software will lack a lot of features.
One of the few things I really miss from the Amiga is the ability to check/uncheck multiple menu items without dismissing the menu. Case in point: the Options menu of SysInternals’ Process Explorer.
I guess it wouldn’t exactly be chording, but clicking the right mouse button on a menu item currently does nothing. It would be very convenient if a right-click could toggle menu item check marks and still leave the menu open, so that you could set all your options without repeatedly dropping down the menu. Of course, this behavior would probably break sole existing programs.
@dean harding:
the point was that the ctrl and atl chording is is solved the same was the chording mouse button is : with the existing messages.
ulric: Oh sorry, I thought you were talking from the user’s perspective, not a developer’s perspective. Carry on, then :-)
I thought of Minesweeper too, and it’s really hard to play on a two-button mouse, and it’s even more annoying when you realise that right-mousing on a revealed square could have been used instead.
I don’t know whether it has improved recently but I remember finding it impossible to reliably detect mouse chording in Java and/or JavaScript.
@Nick Lamb: Actually, ctrl-c / ctrl-v doesn’t work very well in X. It’s dependent on the windowing environment – it usually doesn’t work between X, GNOME and KDE apps, for example, because there is no clipboard standard. Other than the plain old highlight-and-middle-click. Which only works for text. Copying non-text in X is an exercise in frustration (again, especially between X, GNOME, and KDE apps, but there seem to be others as well).
CTRL-C in an xterm or terminal wannabe usually ends up as SIGINT or something, so modern terminals use the PC/DOS shift-insert style.
Middle-click is about the only paste method that works in all X scenarios – down to simple x terminals I’ve used…
Check out acme editor from Plan9/inferno, or if you’re on windows, try acme-sac. That’s an application where I see mouse chording is used a lot.
For another real world example where mouse button chording is an option, and a pretty useful one at that, try the Opera browser. I’m not sure if it’s enabled by default or as part of the optional mouse gestures, but left clicking while the right button is held down is Back, and the opposite is Forward. I find these to be easier to use than the equivalent gestures (right-click and drag right for forward, and left for backward), especially when using a laptop.