xlinuks
June 12th, 2008, 11:16 AM
Hi, can someone please write a working snippet so that when clicking on a Gtk::DrawingArea it prints "clicked"?
I tried binding signal handlers but couldn't. It compiles fine but doesn't work.
I have
class PaintArea : public DrawingArea {...}
Then inside the constructor I write:
signal_button_press_event().connect( sigc::mem_fun( *this, &PaintArea::onMouseDown ) );
The onMouseDown method is:
bool PaintArea::onMouseDown( GdkEventButton *event ) {
cout << "clicked" << endl;
return true;
}
But I never get to see the "clicked" line printed.
On the other hand the on_expose_event works fine, but unfortunately I not only need to do custom painting but also track the mouse events.
I tried binding signal handlers but couldn't. It compiles fine but doesn't work.
I have
class PaintArea : public DrawingArea {...}
Then inside the constructor I write:
signal_button_press_event().connect( sigc::mem_fun( *this, &PaintArea::onMouseDown ) );
The onMouseDown method is:
bool PaintArea::onMouseDown( GdkEventButton *event ) {
cout << "clicked" << endl;
return true;
}
But I never get to see the "clicked" line printed.
On the other hand the on_expose_event works fine, but unfortunately I not only need to do custom painting but also track the mouse events.