key_release_event with GtkText widget
- From: Philip Bunce <pjb carmel com>
- To: gtk-list gtk org
- Subject: key_release_event with GtkText widget
- Date: Fri, 25 Jan 2002 16:41:09 -0800
Hi,
I am trying to get each keystroke from a GtkText widget as the user types.
I have successfully captured the key_press_events and retrieved the key pressed, but for the Shift and Control keys
I need to detect the key_release also. I tried adding code for that but I never see a single key_release_event.
Can someone tell me what I am doing wrong please?
Here are the relevant bits of code....
gint cb_sailsim_text_key( GtkWidget *widget, GdkEventKey *event, gpointer data)
{
int key = event->keyval;
char *fmt = 0;
if (event->type == GDK_KEY_PRESS) {
if ((key >= 0x20) && (key <= 0xFF)) {
if (sailsim.shift) key = toupper(key);
else if (sailsim.ctrl) {
key = toupper(key);
fmt = "^";
}
printf("I got a %s%c\n", (fmt)?fmt:"",key);
}
else if (key == 0xffe1) sailsim.shift = 1;
else if (key == 0xffe3) sailsim.ctrl = 1;
else
printf("I got some other key %02x\n",event->keyval);
}
else {
printf("key_release: %x\n",key);
if (key == 0xffe1) sailsim.shift = 0;
else if (key == 0xffe3) sailsim.ctrl = 0;
}
return TRUE;
}
gtk_signal_connect (GTK_OBJECT (sailsim.text), "key_release_event",
GTK_SIGNAL_FUNC(cb_sailsim_text_key), NULL);
gtk_signal_connect (GTK_OBJECT (sailsim.text), "key_press_event",
GTK_SIGNAL_FUNC(cb_sailsim_text_key), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]