Re: Goocanvas::Widget - embedded widget events



Hi Murray,

thanks for the hint with the signal handler sequence, that did the trick.

I'm still having some difficulties with what i'm trying to accomplish. As 

i mentioned before, i'd like to add standard Gtk::Widgets to the Goocanvas::Canvas.

They should be moveable, as in the goocanvasmm moving_shapes example. Therefore,

i need to connect various mouse signals to signal handling functions. In those handlers,

i need to check which Goocanvas::Widget container holds the widget, so i can move

it around. I'd need to pass a reference to the widget that emitted the signal.

As i found out in this tutorial, it should be possible to pass extra arguments to the signal handler:

http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-binding-extra-arguments.html

This works with passing an additional Glib::ustring like in the example, but the compilation fails

when binding the Gtk::Widget itself:

m_button1.signal_clicked().connect( sigc::bind<Gtk::Widget&>( sigc::mem_fun(*this, &HelloWorld::on_button_clicked), widget) );

with the function having the following signature:

bool HelloWorld::on_button_clicked(GdkEventButton* event, Gtk::Widget& widget)


i get tons of compiler errors and don't want to make this mail too long, so i pasted it here: http://pastebin.ca/1253328

i've also tried not to use the reference operator in sigc::bind<Gtk::Widget&>, which results in :

/usr/include/gtkmm-2.4/gtkmm/widget.h:317: error: 'Gtk::Widget::Widget(const Gtk::Widget&)' is private

errors.

Does anyone of you know how this can be done ?


thanks again!


-robert

On Tue, Nov 11, 2008 at 10:46 AM, Murray Cumming <murrayc murrayc com> wrote:
On Mon, 2008-11-10 at 23:36 +0000, Damon Chaplin wrote:
> On Mon, 2008-11-10 at 23:11 +0100, Robert Gruendler wrote:
> > Hi all,
> >
> > As i've found out in the old mailing list, events like button_press_event
> > won't be dispatched by the Goocanvas::Widget itself.
> >
> > i'm trying to handle events dispatched by the embedded widgets in a
> > Goocanvas::Widget, but my callback function doesn't get called:
> >
> >
> > Gtk::Button widget;
> > Glib::RefPtr<Goocanvas::Widget> wid;
> > wid = Goocanvas::Widget::create(widget,10,10,40,40);
> > _canvas->get_root_item()->add_child(wid);
> >
> > widget.signal_button_press_event().connect(sigc::mem_fun(*this,
> > &MyWindow::on_widget_button_press_event));
> >
> >
> > Has anyone a hint what i'm missing out here ?
>
> Maybe the button handler is being called first, and returns TRUE so the
> signal emission is stopped.

Robert, you should try connecting _before_, as with X event signals in
general. See "Signal handler sequence" here:
http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-xeventsignals.html

--
murrayc murrayc com
www.murrayc.com
www.openismus.com




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