Re: Events in custom widgets



Il Thu, 14 Jan 2016 08:41:46 +0100 Jozef Molnar <jv molnar googlemail com> scrisse:

Dear subscribers,

I want to create a custom widget derived from either GtkDrawingArea or
GtkLayout (still do not know, which is better for my purpose - I need some
advice).
Nevertheless, if I derive my widget from GtkDrawingArea, I can draw using
Cairo (the draw callback gets called) but I cannot receive mouse events. I

Hi Jozef,

GtkDrawingArea *can* handle mouse events. From its documentation:

    To receive mouse events on a drawing area, you will need to
    enable them with gtk_widget_add_events().

so I suspect you are missing that call in your testing code. E.g.

    gtk_widget_add_events(drawing_area, GDK_POINTER_MOTION_MASK);

enables you to connect a callback to the "motion-notify-event"
signal of your drawing area.

Ciao.
-- 
Nicola


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