Article # 27, added by Geoworks, historical record
| first | previous | index | next | last |

Control key and mouse press



Q:
How do I detect when the user is holding the Control key and clicking the
mouse button at the same time? Also, what about the Shift keys? 

A:
When you receive a MSG_META_START_SELECT, you will get a parameter called
inputState. The high byte of this word parameter contains data indicating
the special mode of the mouse click. For a normal mouse click, the
following bits are set: 

    UIFA_SELECT | UIFA_IN

For a Control-click (holding Control key while clicking mouse):
    UIFA_SELECT | UIFA_PREF_A | UIFA_IN

For a Shift-click (holding Shift key while clicking mouse):
    UIFA_SELECT | UIFA_CONSTRAIN | UIFA_PREF_B | UIFA_IN

So, to detect when the user is holding down the Control key and clicking
the mouse at the same time, do this in your MSG_META_START_SELECT method: 

    if ( GET_UI_FUNCTIONS_ACTIVE( inputState ) & UIFA_PREF_A ) {
        /* User clicking while pressing Control */
    }

For detecting when the user is pressing the Shift key and clicking:
    if ( GET_UI_FUNCTIONS_ACTIVE( inputState ) & UIFA_PREF_B ) {
        /* User clicking while holding Shift key. */
    }