PDA

View Full Version : detecting back and forward buttons on >= 5 button mouse



chezifresh
4th February 2011, 03:05
So, in the Qt namespace you get the following button enumerations. Is there a good way to tell which button is the forward button and which is the back?

On Linux, I understand that this is stored in something like xmodmap, even if I knew how to get that information programmatically, I'm still not sure how to map XButton1 or XButton2 to those values.

Constant Value Description
Qt::NoButton 0x00000000 The button state does not refer to any button (see QMouseEvent::button()).
Qt::LeftButton 0x00000001 The left button is pressed, or an event refers to the left button. (The left button may be the right button on left-handed mice.)
Qt::RightButton 0x00000002 The right button.
Qt::MidButton 0x00000004 The middle button.
Qt::XButton1 0x00000008 The first X button.
Qt::XButton2 0x00000010 The second X button.

Any ideas on how to do this? I would imagine someone out there has solved this problem. I was expecting to find the answer in one of Qt's webkit examples but didnt locate anything.

high_flyer
4th February 2011, 08:50
There are two options as I see it:
1. These button are standardized.
If so, just test it, and you know which is which.
2. There is no standard.
In that case, offer a settings dialog, where the user can set which button is which.


(The left button may be the right button on left-handed mice.)
I don't think this is true.
A true left-handed mouse probably switched the buttons as well.
In addition, this is something you can change over the mouse settings of the OS.

chezifresh
4th February 2011, 18:44
You might be right about just testing them and assuming they're standardized. I supposed a few carefully planned tests could show what happens when you change settings in your xmodmap to see if Qt is getting raw mouse events or if they are in fact going through X's button mappings first. I was just hoping someone had a definitive answer. I'm just messing around with creating a directory browser and thought it would be nice to enable those buttons for navigation.

Also just so you know, the left button/right button swap comment didnt come from me, I copied that text from the Qt 4.6 documentation for the Qt namespace

high_flyer
4th February 2011, 20:45
Also just so you know, the left button/right button swap comment didnt come from me, I copied that text from the Qt 4.6 documentation for the Qt namespace
Well, they are human too, the trolls ;)
I just don't see the point of having a left handed mouse (that means it was ergonomically designed to be held left handed) and not swap the buttons - what sense would that make?
It would be equivalent to a normal mouse with swapped buttons.
The trolls probably put it there to cover this possibility.

Anyway, as I said, this can be set from the OS mouse settings, so eventually, this doesn't really matter, since you can change the buttons functions as you see fit.
It is not important on which side the button is, it is important what FUNCTIONALITY the pressed button has (as in the OS mouse settings).
In that regard the "left mouse button" is not necessarily on the left, but rather the button configured with the functionality of the "left button"(i.e selecting etc, and not for the context menu).