Re: Testing keyboard state



On Tue, 2008-01-15 at 20:17 +0000, John Franklin wrote:
I've just started using GTK and Glade to develop a small app
I want to determine if the Ctrl key is also pressed.

GdkModifierType.

When the 'key-press-event' signal or 'key-release-event' signal are
emitted, the handler you hookup includes an argument of type
GdkEventKey.
http://library.gnome.org/devel/gtk/2.12/GtkWidget.html#GtkWidget-key-press-event
http://library.gnome.org/devel/gdk/2.12/gdk-Event-Structures.html#GdkEventKey

The GdkEventKey struct, in turn, has a field called "state" which is a
bitmask of the various flags in GdkModifierType. You check for
GDK_CONTROL_MASK being set when you get a key pressed.
http://library.gnome.org/devel/gdk/2.12/gdk-Windows.html#GdkModifierType

++

I've found some SDL library functions

In general, you do not want to mix toolkits, and in this case you
certainly don't need or want to use SDL. GTK and the rest of the GNOME
libraries provide everything you need to manage a graphical user
interface.

GTK isn't blocking the keyboard handling of course (else nothing on the
GNOME Desktop would work!). You just need to work with it according to
the APIs it presents.

AfC
Sydney
-- 
Andrew Frederick Cowie

We are an operations engineering consultancy focusing on strategy,
organizational architecture, systems review, and change management
procedures: enabling successful use of open source in mission
critical enterprises, worldwide.

http://www.operationaldynamics.com/

Sydney   New York   Toronto   London


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