GTK:在scrolled_window滚动后获取滚动事件上的指针位置

发布于 2024-12-22 15:35:22 字数 472 浏览 4 评论 0原文

我在滚动窗口内有一个绘图区域(带有方便的视口), 并且该绘图区域会根据传入的运动通知事件进行自我更新。 当我滚动该区域时,虽然显然没有发出任何运动事件, 但我想解决这个问题,所以尝试连接绘图区域 “滚动事件”信号发送至相同的运动通知回调。

我在这里面临的问题是这个信号是在滚动窗口之前发出的 已更新其视口,因此在回调中,我最终得到了在滚动之前为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情泪▽动烟 2024-12-29 15:35:22

解决方案是连接到 "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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文