In GTK+3, how do I get a drawingarea to respond to mouse events?

Viewed 3822

In GTK+3, how do I get a drawing_area to respond to mouse events?

In main() function I declared my drawing_area:

GtkWidget *drawing_area;

Then I connected the drawing_area with the mouse click signal:

g_signal_connect(drawing_area, "button-press-event", G_CALLBACK(clicked), NULL);

the function "clicked" is defined by:

static gboolean clicked(GtkWidget *widget, GdkEventButton *event, gpointer user_data)

    printf("Clicked! \n");

    return TRUE;
}

The program runs and shows the drawing_area but when I click on it, no answer, nothing happens! Why is this happening?

2 Answers
Related