Re: Getting keyboard state.
- From: Philip Kendall <pak ast cam ac uk>
- To: GTK+ faq <gtk-app-devel-list redhat com>
- Subject: Re: Getting keyboard state.
- Date: Fri, 12 Jan 2001 10:50:41 +0000
On Fri, Jan 12, 2001 at 01:06:24PM +0700, Maxim Koshelev wrote:
Hi there!
Does somebody know how to get state of the keyboard via gtk/gdk?
I just need to know about current state of Shift key in my program.
Connect handlers to both the `key-press-event' and `key-release-event'
for the appropriate widgets. (`key-release-event' isn't received by
default, so you'll need a call along the lines of
gtk_widget_add_events( widget, GDK_KEY_RELEASE_MASK );
to make sure you get them).
Then every time you get a key press event with event->key.keyval being
either `GDK_Shift_L' or `GDK_Shift_R', set a flag. Clear the flag on the
corresponding key release events (making sure you deal properly with a
sequence like Shift_L pressed, Shift_R pressed, Shift_R released).
Or if you only need shift when combined with other keys, just look at
bit 0 of event->key.state.
HTH,
Phil
--
Philip Kendall <pak ast cam ac uk>
http://www.srcf.ucam.org/~pak21/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]