Testing keyboard state



Thanks, Andrew.  In fact I needed the button-pressed-event to check the Ctrl state when a mouse is clicked 
(and which passes a similar structure to the handler), but you pointed me in the right direction.

With regards,

John Franklin


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



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