Help: GdkEventKey callback
- From: Cuong Tran <cuong h tran att net>
- To: gtk-app-devel-list gnome org
- Subject: Help: GdkEventKey callback
- Date: Thu, 11 Oct 2001 13:16:43 -0500
Hi,
I tried to register a callback for key_release_event associated with a
text widget using gtk_signal_connect(). But it did not seem to work. I
am using GTK 1.2.
The code is below. Any suggestions?
Thanks,
Mike Tran
------------
/*
* textarea.c
*/
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
static GtkWidget *textarea;
static gint key_release_callback(GtkWidget *widget, GdkEventKey *event,
gpointer data );
void CreateTextArea(GtkWidget *window, GtkWidget *container)
{
GtkWidget *table;
GtkWidget *hscrollbar;
GtkWidget *vscrollbar;
GdkFont *textfont;
GtkStyle *style;
/* create a table to put text widget and scrollbars */
table = gtk_table_new(2, 2, FALSE);
/* no gaps between scrollbars and the text */
gtk_table_set_row_spacing( GTK_TABLE(table), 0, 2);
gtk_table_set_col_spacing( GTK_TABLE(table), 0, 2);
gtk_container_add(GTK_CONTAINER(container), table);
/* create text area */
textarea = gtk_text_new(NULL, NULL);
gtk_signal_connect(GTK_OBJEC(textarea),"key_release_event",
GTK_SIGNAL_FUNC(key_release_callback), ULL);
/* +++ other stuffs +++ */
}
static guint last_keyval = 0;
static gint key_release_callback(GtkWidget *widget, GdkEventKey *event,
gpointer data )
{
last_keyval = event->keyval;
#ifdef DEBUG
g_print("lastkey=%x\n", last_keyval);
#endif
/* will do something eventually */
return FALSE; /* to other handlers */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]