Hey I am using c++ to write a program which has a drawing area. I need to make it possible to detect mouse signals from the drawing area and draw points at these positions. How can I do this? There are not many forums which help with this stuff and the documentation is not clear. Can somebody please help me?
Share
Drawing in a gtk3 application is done in response to the “draw” signal. You connect a callback function to the “draw” signal, and when gtk+ needs to redraw the window, your callback is invoked.
The callback looks something like this:
Now, to handle mouse clicks, you’ll need to connect another callback function to “button-press-event”:
See the drawing area reference docs for a small example and the drawing area demo for a complete application.