Search code examples
eventsgtkgtkmmnotifymotion

Cannot catch signal_motion_notify_event in gtkmm


I used following code to catch motion notify events on a Gtk::TreeView.

// This is the Gtk::Builder from which i read my tree view.
builder_ptr->get_widget("treeview", m_treeview_ptr);

// Connecting that event.
m_treeview_ptr->add_events(Gdk::POINTER_MOTION_MASK |
                           Gdk::POINTER_MOTION_HINT_MASK);
m_treeview_ptr->signal_motion_notify_event().connect(
    sigc::mem_fun(this, &LayoutEditorDialog::_on_motion_notify));

My slot function looks like this:

bool LayoutEditorDialog::_on_motion_notify(GdkEventMotion* event) const
{
    // Just a test.
    std::cout << event->x << " " << event->y << std::endl;
}

Somhow no motion notify events will be sent from the tree view. Can someone help me here? Thanks!


Solution

  • I just needed to use connect_notify instead of notify, because my signal is from a event.