Re: connect_notify weirdness, once again...

Murray Cumming wrote:
On Tue, 2005-04-05 at 21:50 +0000, Matthias Kaeppler wrote:


I'm once again having trouble using connect notify. I'm still uncertain why I
need this function at all, the documentation is lacking at this point.

What I want to do is showing a context menu when the client right-clicks my
treeview. Okay, here come the questions:

1. The documentation says I either have to inherit from TreeView and overwrite
on_button_press_event() or use connect_notify to bind an own function from which
I call the base class handler. What's the reasoning here? Why can't I just
directly override on_button_press_event()?

You can, as you said above.

But you often can not connect a signal with connect() instead of
connect_notify(), because the existing signal handler specifies (via the
return value) that other signal handlers (yours) should not be called.
This is not a great API, but luckily
1) It's only for X-Event signal handlers, and they are relatively rare.
2) It's documented.

There's a bug open about this. I haven't given up hope of making this
simpler in future:
(The TreeView is mentioned in a dependent bug.)

Is this also the case for the signal_button_press_event?
Because I am connecting (not connect_notify'ing) a signal handler which returns a boolean to that signal, and it is never called. OTOH, this signal handler (handling mouse button presses) doesn't sound to be "rare":

class MyWidget: public Gtk::ScrolledWindow
    bool on_button_press_event( GdkEventButton* );
// ...
    Gtk::TreeView view_;
// ...

// ...
view_.signal_button_press_event().connect( sigc::mem_fun( *this, &MyWidget::on_button_press_event ) );

The signal handler is never called. I have to declare it void and connect with connect_notify().
I still don't get the point.

PS: Can you also reply to my other post regarding signal handlers in general, i.e. when signal_button_press_event is fired if I have an overlapping view and a widget, which both can fire this event.

Thanks in advance.
Matthias Kaeppler

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