signal emission process



Here's what the current-ish GTK+ 1.2 tutorial says about signal
emissions (its more complete, in some respects, than Havoc's book):

----------------------------------------------------------------------

18.2 Signal Emission and Propagation 

Signal emission is the process whereby GTK runs all handlers for a specific object and signal. 

First, note that the return value from a signal emission is the return
value of the last handler executed. Since event signals are all of
type GTK_RUN_LAST, this will be the default (GTK supplied) handler,
unless you connect with gtk_signal_connect_after().

The way an event (say "button_press_event") is handled, is: 

       Start with the widget where the event occured. 
       Emit the generic "event" signal. If that signal handler returns a value of TRUE, stop all processing. 
       Otherwise, emit a specific, "button_press_event" signal. If that returns TRUE, stop all processing. 
       Otherwise, go to the widget's parent, and repeat the above two steps. 
       Continue until some signal handler returns TRUE, or until the top-level widget is reached. 

Some consequences of the above are: 

       Your handler's return value will have no effect if there is a
       default handler, unless you connect with
       gtk_signal_connect_after().  To prevent the default handler
       from being run, you need to connect with gtk_signal_connect()
       and use gtk_signal_emit_stop_by_name() - the return value only
       affects whether the signal is propagated, not the current
       emission.
----------------------------------------------------------------------

>From what I can tell, this appears to be wrong. If I connect a key
press handler to the top level window, and a different handler to
a widget within that window, then:

  1) both handlers are invoked for any keypresses in the child widget
  2) they are invoked with different widget arguments
  3) most importantly, the top level window callback is invoked first
  4) the return value of the callbacks do not affect them both
     being called

So, it would actually appear that things happen in the reverse order
to the one give above: the top-level widget is consulted first, then
each successive child widget. 

Can anyone who really knows the answer let me know ?

--p




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