Re: GdkPixbuf and click events



Op 08/03/2017 om 12:02 AM schreef Ferdinand Ramirez via gtk-app-devel-list:
I have a program that adds a GdkPixbuf to a GtkTextView. I would like to right click on the image and 
capture the mouse click event and execute a callback function. Is there any way of achieving this using 
GdkPixbuf?

Not directly with a pixbuf but this is what a GtkDrawArea [1] is for.
Create a new drawing area and add the event mask you are interested in
(GDK_BUTTON_PRESS_MASK for example) with gtk_widget_add_events. Finally
connect to the signal corresponding to the event (following earlier
example button-press-event) and do what you want in a callback function.

Note that you have to handle drawing yourself which the docs provide an
example of.

~infirit

[1] https://developer.gnome.org/gtk3/stable/GtkDrawingArea.html



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