GTK:在scrolled_window滚动后获取滚动事件上的指针位置
我在滚动窗口内有一个绘图区域(带有方便的视口), 并且该绘图区域会根据传入的运动通知事件进行自我更新。 当我滚动该区域时,虽然显然没有发出任何运动事件, 但我想解决这个问题,所以尝试连接绘图区域 “滚动事件”信号发送至相同的运动通知回调。
我在这里面临的问题是这个信号是在滚动窗口之前发出的 已更新其视口,因此在回调中,我最终得到了在滚动之前为 true 的指针坐标,使其看起来在滚动时绘图区域始终“落后于实际指针一步”,而不移动指针本身。 我以为我可以通过使用 gdk_window_get_pointer 手动提取坐标来弥补这一点,但后来我意识到这不起作用,因为当回调开始时,指针在技术上仍处于其旧位置。 我还尝试使用 g_signal_connect_after 希望它能在视口滚动后调用回调,但它没有帮助。
我最后的希望是在滚动事件上启动一个计时器,并在最短的时间后触发回调,但这听起来真的很难看,我想不惜一切代价避免这种情况。
关于如何实现这一点有什么想法吗? 提前致谢!
I've got a drawing area inside a scrolled window (with convenience viewport),
and this drawing area updates itself according to incoming motion-notify-events.
When I scroll the area though obviously no motion events are emitted,
but I wanted to work around this, and so tried to connect the drawing area's
"scroll-event" signal to the same motion-notify callback.
The problem I'm facing here is that this signal is emitted before the scrolled window
has update its viewport, so in the callback, I end up with pointer coordinates that were true just before scrolling, making it look like the drawing area is always "lagging a step behind" the actual pointer when scrolling while not moving the pointer itself.
I thought I could compensate for this by manually extracting the coordinates with gdk_window_get_pointer, but then I realized this cannot work as the pointer is technically still at its old position when the callback is commencing.
I also tried using g_signal_connect_after in hopes it would have the callback get called after the viewport was scrolled, but it didn't help.
My last hope would be to start a timer on scroll-events, and have the callback fire after a minimal amount of time, but this sounds realllly ugly, and I'd like to avoid that at any cost.
Any ideas as to how this could be realized?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是连接到 "value-changed " GtkScrolledWindow 信号
调整。
来源: https://mail.gnome.org /archives/gtk-app-devel-list/2011-September/msg00014.html
A solution would be to connect to the "value-changed" signal of the GtkScrolledWindow
adjustments.
Source: https://mail.gnome.org/archives/gtk-app-devel-list/2011-September/msg00014.html