Re: [gtk-list] gtk_signal_connect() w/key_press_event
- From: Tim Janik <timj gtk org>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] gtk_signal_connect() w/key_press_event
- Date: Thu, 14 May 1998 10:41:56 +0200 (CEST)
On Wed, 13 May 1998, Michael J. Hammel wrote:
> Using gtk_signal_connect() for a key_press_event in a GtkText widget causes
> the callback routine to be passed the widget id of the GtkText widget and
> the GdkEventKey structure. However, there doesn't appear to be any way to
> pass in user data to this callback. How can you pass in the user data (arg
> 4 of gtk_signal_connect()) to the callback? I need to pass in a data
> structure of information to this callback. Is that what the "string"
> element of the GdkEventKey structure is for? If so, should that be an
> opaque gpointer instead of a gchar type?
>
> If this isn't possible using gtk_signal_connect(), how can I catch keystrokes
> in a GtkText widget and have them cause a callback to be called with my data
> structure passed in to it?
gtk_signal_connect (GTK_OBJECT (text),
"key_press_event",
GTK_SIGNAL_FUNC (my_func),
my_data);
static gint
my_func (GtkWidget *widget,
GdkEventKey *event,
gpointer func_data)
{
GtkText *text;
gpointer my_data = func_data;
gboolean handled = FALSE;
text = GTK_TEXT (widget);
/* intercept key presses
*/
if (event->keyval == GDK_Return)
{
printf ("huhu\n");
gtk_signal_emit_stop_by_name (GTK_OBJECT (text), "key_press_event");
handled = TRUE;
}
return handled;
}
> --
> Michael J. Hammel | Simba: "Hey, why'd you do that?"
> The Graphics Muse | Baboon: "It doesn't matter! Its in the past!"
> mjhammel@graphics-muse.org | The Lion King
> http://www.graphics-muse.org
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]