Gtk+ 鼠标指针离开区域事件
我需要检测鼠标指针何时离开 GtkNotebook 中的区域。 通常,这可以通过 Motion_notify 事件实现,但如果指针移动得足够快,则不会触发该事件。 因为这是 GtkNotebook 中的某个像素区域,所以不可能使用 GtkEventBox。 执行此操作的正确方法是什么?
I need to detect when the mouse pointer leaves an area in a GtkNotebook. Normally this is possible with the motion_notify event, but if the pointer is moved fast enough, the event is not triggered. Because this is a certain area of pixels in a GtkNotebook, it is not possible to use a GtkEventBox. What is the proper way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用
enter-notify-event
和leave-notify-event
信号。You should use
enter-notify-event
andleave-notify-event
signals.您一定会收到进入和离开通知,但只能收到定期的运动通知。 如果指针移动得足够快,您将不会收到有关您关心的区域内的坐标的通知。
实现 100% 效果的唯一方法是在您的小部件层次结构中构建一个 EventBox(或其他一些窗口小部件)来封装此空间。 请记住,您可以根据多个小部件来定义区域。
最后,如果您没有收到来自小部件的进入或离开通知,您可能必须修改小部件的事件掩码。
You are guaranteed to get enter and leave notifications, but only periodic motion notifications. if the pointer is moving fast enough, you won't get a notification for coordinates within the area you care about.
The only way to catch this 100% is to bulid an EventBox (or some other windowed widget) into your widget hierarchy that does encapsulate this space. Keep in mind that you may be able to define the region in terms of multiple widgets.
Finally, if you aren't receiving enter or leave notifications from a widget, you likely have to modify the widget's event mask.