Moveable Goocanvas::Widgets


i'm trying to put native Gtk Widgets like Gtk::Button on a canvas. The canvas should have 2 modes, a locked and an unlocked mode. in the unlocked mode, the widgets should be moveable with the mouse, in the locked mode they should act as they usually do, ie. a Gtk::Button dispatches its signal_clicked() event etc.

I was unable to detect the button_press, -release or motion_notify events on the Goocanvas::Widget objects itself, even when passing false to the 'after' parameter of the connect method. So i'm simply listening to the signals of the native Gtk::Widget objects, which for some reason only works for the button_press and button_release signals. The signal_motion_notify_event is never dispatched from those widgets on the canvas.

This resulted in the next workaround, listening to the motion notify event on the canvas itself, handling the dragging logic in there, which brought me to a point where i'm really stuck now. The motion_notify_event from the Goocanvas::Canvas itself is dispatched correctly, even if the mouse is over a child Widget. However, i'm not receiving the signal anymore as soon as the left mouse button is clicked on a widget on the canvas...

_canvas->signal_motion_notify_event().connect(sigc::mem_fun(*this, &MyWindow::on_canvas_motion_notify_event, false);

bool MyWindow::on_canvas_motion_notify_event(GdkEventMotion* event) { // <-- not called when the mouse button has been pressed on a widget on the canvas std::cout << "motion detected" << std::endl; }

Does anyone know why this is happening ?
Any hints greatly appreciated, thanks !


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