GTK:获取窗口中鼠标单击的坐标
在 GTK 中,我无法弄清楚要设置什么回调,以便当用户在窗口中单击时,我可以获得单击的 X/Y 坐标。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找
按钮-press-event
GtkWidget
信号。You're looking for the
button-press-event
signal ofGtkWidget
.回调中的事件参数通常获取 ax 和 ay 成员,它们是鼠标坐标。如果您需要示例,请查看 gtk 教程,其中有一个小型绘图程序的示例代码,您可以在其中了解如何处理鼠标事件
http://www.gtk.org/tutorial1.2/gtk_tut-23.html
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