Overriding on_motion_notify_event



I'm trying to override the virtual function on_motion_notify_event in a
Gtk::DrawingArea, but the function never seems to be called. I don't get why,
since DrawingArea inherits from Widget.  So, when does a motion notify event ever occur?

Here's a minimal example of what I mean:

#include <iostream>
#include <gtkmm.h>

class Area: public Gtk::DrawingArea
{
public:
  Area () {}
private:
  //never called?
  virtual bool on_motion_notify_event (GdkEventMotion *event)
  {
    std::cout << event->x << '\t' << event->y << '\n';
  }
};

int main (int argc, char **argv)
{
  Gtk::Main test (argc, argv);
  Gtk::Window window (Gtk::WINDOW_TOPLEVEL);
  Area area;
 
  window.add (area);
  window.show_all ();
 
  test.run (window);
}



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