void add_events(GdkEventMask events);

Lets the widget receive more events by adding the event masks to the list of to-be-notified-of event types.

With that, you can let e.g. a GtkButton receive "motion-notify-event"s which it doesn't do by default.

Example 150. Tracking mouse movement on a button with add_events

* We let the button receive an event that normally
* is not recognized by using GtkWidget::add_events()
$btn = new GtkButton('move the mouse');
$btn->connect('motion-notify-event', 'onMouseOver');

function onMouseOver($btn, $event) {
    $btn->set_label($event->x . ', ' . $event->y);

$wnd = new GtkWindow();
$wnd->set_default_size(200, 100);
$wnd->connect_simple('destroy', array('Gtk', 'main_quit'));

See also: get_events() , set_events()