Re: GtkDrawingArea & signal



Hi,

Jean-Yves Lamoureux <jylam lnxscene org> writes:

> I would like to get events on a GtkDrawingArea, especially the mouse clicks 
> and mouse position.
> I wrote that : 
> 
>   gtk_signal_connect (GTK_OBJECT (MyWindow->MyDrawingArea), "clicked",  
> GTK_SIGNAL_FUNC (MyHandler), GTK_OBJECT (file_menu));  

you are trying to connect to the "clicked" signal but a GtkDrawingArea
doesn't have such a signal (GtkButton has for example).

>   gtk_widget_set_events (GTK_OBJECT (MyWindow->MyDrawingArea), 0 );

huh? Why are you emptying the event_mask?

Have a look at the scribble-simple example in the gtk+ docs to see how 
button_press events are properly handled. Basically you need something
like:

 gtk_widget_add_events (widget, GDK_BUTTON_PRESS_MASK);
 gtk_signal_connect (widget, "button_press_event", callback, data);

You can then access the pointer position thru the GdkEventButton that
is passed to your callback.


Salut, Sven



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]