Re: connect_notify weirdness, once again...



On Sun, Apr 10, 2005 at 06:35:32PM +0200, Matthias Kaeppler wrote:
> Murray Cumming wrote:
> >On Tue, 2005-04-05 at 21:50 +0000, Matthias Kaeppler wrote:
> >
> >>Hello,
> >>
> >>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:
> >http://bugzilla.gnome.org/show_bug.cgi?id=126213
> >(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
> {
> public:
>     bool on_button_press_event( GdkEventButton* );
> // ...
> private:
>     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.
Maybe you want to use "add_events(GDK_BUTTON_PRESSMASK)" in the
constructor of MyWidget. By default, the window will not be sent
button_press event.
> 
> 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.
I think the one on the above will fire the button_press_event. But I
don't quite understand you. Do you mean the widget lies in the view ?
> 
> 
> Thanks in advance.
> -- 
> Matthias Kaeppler
> 
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 
-------------------------




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