获取 gtk 滚动窗口中的鼠标位置
我有一个带有视口的滚动窗口,高度约为 4000 像素。有没有办法计算出鼠标在视口坐标中的位置?目前,我得到的位置是我实际看到的段中的位置,如果我向下滚动到底部,我仍然会得到类似 600 像素的垂直位置(即我的窗口的大小) ,而不是我期望的 4000。如果没有简单的方法,如何确定滚动窗口滚动了多少?我相信,我可以把这些碎片拼凑起来。
谢谢,
v923z
I have a scrolled window with a viewport, which is some 4000 pixels tall. Is there a way to figure out the mouse position in viewport coordinates? At the moment, what I get for the position is the position in the segment that I actually see, and if I scroll down to the bottom, I still get something like 600 pixels for the vertical position (that is the size of my window), instead of the 4000 that I expect. If there is no easy way, how can one determine by how much the scrolled window is scrolled? I believe, I could then put the pieces together.
Thanks,
v923z
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找 get_vadjustment 方法 的scrolled_window。
例如,如果将 button_press_event 绑定到滚动窗口:
将打印 y 位置 + y 方向滚动的量。
You are looking for the get_vadjustment method of the scrolled_window.
For instance if you bind the button_press_event to the scrolled window:
Would print the y position + the amount it is scrolled in the y direction.