button-press-event

This signal is emitted when a mouse button has been pressed down.

Useful event properties are:

  • x, y - The x and y widget coordinates at which the cursor is.
  • button - Mouse button (1 - left, 2 - middle, 3 - right)
  • state - Bitmask of other keys that were pressed (e.g. Ctrl or Shift) - GdkModifierType
  • type - Event type, e.g. normal press, double click or so - GdkEventType.

Example 154. Using the key-press-event signal

<?php
$wnd = new GtkWindow();
$wnd->connect_simple('destroy', array('Gtk', 'main_quit'));

//we want to receive mouse button press events
$wnd->set_events(Gdk::BUTTON_PRESS_MASK);
$wnd->connect('button-press-event', 'onButtonPress');

//here we handle the mouse button press events
function onButtonPress($widget, $event) {
    $widget->set_title($event->button . ' - ' . $event->x . ':' . $event->y);
}
$wnd->show();

Gtk::main();
?>

Callback function

bool callback(GtkWidget widget, GdkEvent event);