Mouse events on a Cairo Context



Hi all,

I'm developing an application with C++ and GTK3 but I'm stucked. I've
created a visual application with glade which has three columns and one of
them, the middle one, is a DrawingArea. In that DrawingArea I want to draw
some circles at the point I want to after pressing a button and have
different mouse events on that circles (like drag and drop, double click,
right click...). I've made the first thing (draw a circle after pressing a
button) following the official
documentation<https://developer.gnome.org/gtkmm-tutorial/3.2/chapter-drawingarea.html.en>,
but the problem is that I don't know how to do the mouse events, but I
thought about it and I have some different solutions (I don't know if they
are the bests solutions or maybe there are better):

1 - I think the best way is to create a signal to the cairomm context, but
I didn't see anything to do that. Maybe the way would be to create a cairo
surface or something like that.

2 - Every time I click to create a circle, I would have to create a gtk
widget in which I can handle mouse events. The problem here is that I think
it is impossible to put a widget on a DrawingArea, is it possible?

3 - Use goocanvasmm. The problem here is that goocanvasmm has a little
documentation <https://developer.gnome.org/goocanvasmm/stable/> and I think
this is not the best solution, I prefer to use cairomm.

This application was written in C using GTK2, and the circles were drawn
using gnomecanvas, adding signals in an easy way to each circle; and now
I'm moving this application to C++ and GTK3 to renew it.

I'm very new to GTK (and graphical interfaces in general), but I looked for
solutions for hours and I don't know what is the best way in order to
continue my work. I also looked for similar messages in this list, but I
didn't find it.

Although I think the best way is the first option, I tried to make the
second because I think it is the regular way. Anyway, if you know how to
deal with this problem, could you give me an example of how to do that?

Thank you for your help :)


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