Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GTK: Get co-ords of a mouse click in a window

Tags:

c

mouse

gtk

In GTK I can't figure out what callback to setup so that when the user clicks in a window, I can get the X/Y co-ords of the click.

like image 250
myforwik Avatar asked Oct 27 '25 07:10

myforwik


2 Answers

You're looking for the button-press-event signal of GtkWidget.

like image 74
ptomato Avatar answered Oct 28 '25 21:10

ptomato


The event param in the call back usually get's a x and a y member which are the mouse coordinates. If you need an example have a look at the gtk tutorial, there is the example code of a small drawing program, where you can see how to handle mouse events

http://www.gtk.org/tutorial1.2/gtk_tut-23.html

like image 35
Nikolaus Gradwohl Avatar answered Oct 28 '25 19:10

Nikolaus Gradwohl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!