Re: passing on signals


edscott wilson garcia <edscott imp mx> writes:

>   Does anybody know the correct way to pass on keypressed signals
> received by one widget to another? Either of the following two lines
> causes gtk to segfault when signal received by GtkCombo is passed to
> GtkEntry:
> gtk_signal_emit_by_name (GTK_OBJECT (entry),
> "key_press_event",event,data,NULL);
> gtk_signal_emit_by_name (GTK_OBJECT (entry),
> "key_press_event",event,data);

Both lines are wrong. The user_data that is passed to a signal
callback is not set on signal emission but it's the data set when the
signal was connected. The correct code would be:

 gtk_signal_emit_by_name (GTK_OBJECT (entry), "key_press_event", event);

Actually this is deprecated API, so you would better use the following

 g_signal_emit_by_name (entry, "key_press_event", event);

This code assumes that event is a pointer to a GdkEventKey structure.


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