Re: Events and derived objects



Eduardo M Kalinowski wrote:
[...]
I've achieved capturing some specials keys, but letting everything else work as normally in the TextView by connecting a handler to
a key-press-event of the TextView inside the derived widget's
implementation, but I have'nt discovered how to propagate keys unhandled
by the TextView itself or by my special handler to the user.

If the user wants to treat events that are not handled by the
widget's event handler, they'll have to use g_signal_connect_after
(or the appropriate flag), otherwise the handler will be called
before the default widget's handler.

So the normal chain would be:
   my_ojbect_key_press (connected to textview delagate's
                        key-press-event)
   key_press_cb        (connected by the user using g_signal_connect)
   textview_key_press  (base class handler)
   after_key_press_cb  (connected by the user using
                        g_signal_connect_after)

And ofcourse, the first handler to return TRUE effectively
stops the emission.


Another approach would be to derive an object from GtkTextView,
override the base class handler for class->key_press_event and
from your key_press_event; decide if you want to:

    return GTK_WIDGET_CLASS
           (parent_class)->key_press_event (widget, event);

Cheers,
                          -Tristan



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