ardabro
ardabro

Reputation: 2061

How to be notified about each cursor movement over widget?

I'm newbie in gtk. I need to track mouse cursor position over window. I've found "motion-notify-event" that looked promising but it appeared to be generated only when mouse button is pressed. What to do to be notified about each mouse cursor movement regardless of buttons state?

Upvotes: 1

Views: 184

Answers (1)

Jussi Kukkonen
Jussi Kukkonen

Reputation: 14587

motion-notify-event signal emission requires two things:

  1. The widget must have it's own GdkWindow (this is not true for all widgets but is true for e.g. GtkWindow)
  2. GDK_POINTER_MOTION_MASK must be set in the widget event mask

The latter can be done with:

gtk_widget_add_events (my_widget, GDK_POINTER_MOTION_MASK);

Upvotes: 2

Related Questions