Re: gtkdrawingarea mouse signals



suzan Allen wrote:

Hi everyone,
I am new to this list and to gtk so please be patient with me.
My code contains a gtk window that contains a gtkdrawing area.I know how to draw on that area. But if I want to select a certain area within this "drawing area" to apply a certain action on it. How do I do that. I mean which event should the drawing area receive and how to get the coordinates of the choosen area (it should be rectangular).

There're "motion-notify-event", "button-press-event", "button-release-event" signals. Callbacks prototypes and all other stuff you need described here:
http://developer.gnome.org/doc/API/2.0/gtk/gtkwidget.html

You have to set events mask for you widget in order to receive events. This can be done with gtk_widget_set_events(), gtk_widget_add_events() functions. There's an example, coming with gtk sources: "scribble-simple" (drawing area and mouse handling). Look also at "gtkdial" example - it shows how to deal with mouse events without processing all of them.

*NOTE* in GdkEventButton and GdkEventMotion structures fields *x* and *y* are of type gdouble.

Olexiy





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