Re: gtk_signal_emit_by_name trouble




katre <katre@ruf.rice.edu> writes:

> Hi all,
> 
> In my current project, i have a custom widget which catches key presses at
> certain times (like when the read_str function has been called :).  Users
> being what they are, I expect that people will try typing at the wrong times,
> and then be mad that it doesn't show up, so i would like to add a typeahead
> capability.  I have Everythign set except for the part of actually processing
> the typeahead.  I would like to simply re-emit the signals for the correct
> key_press handler to deal with, but i cannot figure out how to call
> gtk_signal_emit_by_name.  The first argument is the object (in this case my
> custom widget), the second the event, "key_press_event".  But the emit
> function is declared to take variable arguments.  What should these be?

The variable parameters here are the event and the return value;

 GdkEvent event;
 gint result;

 gtk_signal_emit_by_name (object, "key_press_event", &event, &result);

However, you really should use gtk_widget_event () instead
of gtk_signal_emit_by_name () here. 

 gtk_widget_event (object, &event_ptr);

This will work even if the target widget is watching for
the generic "event" instead of the specific "key_press_event".

(In general, you should only emit signals directly that were
created with the GDK_RUN_ACTION flag... Of course, the only
way to find that information out right now is to look
in the source...)

> Where do i tell which key is being pressed?

By filling in the event appropriately.

 event.type = GDK_KEY_PRESS;
 event.key.window = some_win;
 ...

Regards,
                                        Owen



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