Re: How to get <Shift>, <Alt>, <Ctrl> status in gdk




Andreas Tille <tille@physik.uni-halle.de> writes:

> Hello,
> 
> I want to write a program that works with the cursor keys.
> If <Shift>, <Alt> or <Ctrl> are pressed I want to implement a
> different result.  How to ask for a pressed modification key?

When you get a key press event, you can check 

 event->state

For instance, 

 if (event->state & GDK_SHIFT_MASK)
   /* shift key was pressed */

The relevant modifiers in this bitfield are:

/* Types of modifiers.
 */
typedef enum
{
  GDK_SHIFT_MASK    = 1 << 0,
  GDK_LOCK_MASK	    = 1 << 1,
  GDK_CONTROL_MASK  = 1 << 2,
  GDK_MOD1_MASK	    = 1 << 3,
  GDK_MOD2_MASK	    = 1 << 4,
  GDK_MOD3_MASK	    = 1 << 5,
  GDK_MOD4_MASK	    = 1 << 6,
  GDK_MOD5_MASK	    = 1 << 7,
  GDK_BUTTON1_MASK  = 1 << 8,
  GDK_BUTTON2_MASK  = 1 << 9,
  GDK_BUTTON3_MASK  = 1 << 10,
  GDK_BUTTON4_MASK  = 1 << 11,
  GDK_BUTTON5_MASK  = 1 << 12
} GdkModifierType;

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]