NSView鼠标跟踪 [英] NSView mouse tracking

查看:72
本文介绍了NSView鼠标跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac OS X上遇到可可NSView的奇怪行为.

I'm facing a strange behavior with Cocoa NSView on Mac OS X.

我在NSView容器中有一个自定义NSView,该自定义NSView跟踪鼠标的移动,单击并具有工具提示.当我在上述视图上方添加NSView时,即使带有工具提示的视图仍在下面,后面且不可见,我仍然可以看到工具提示.

I've a custom NSView in a NSView container, this custom NSView tracks mouse movements, clicks, and has a tooltip. When I add a NSView above the described view, I can still see the tooltips even if the view with the tooltip is under, behind and not visible.

我很确定我误解了事件处理链中的某些内容.任何帮助,我们都感激不尽!

I'm pretty sure that I misunderstood something in the event handling chain. Any help is really appreciated!

推荐答案

核心问题是在Cocoa中您不应具有重叠的视图.至少,行为然后变得不确定.一个视图可以是另一个视图的子视图,而不仅仅是另一个视图范围内的同级.

The core issue is that you are not supposed to have overlapping views in Cocoa. Or at least, the behavior then becomes undefined. A view can be a subview of another view, but not simply a sibling within the bounds of the other view.

但是,解决您的特定问题的一种方法是使用 setHidden:方法隐藏视图.

However, one way to solve your particular problem is to make the view underneath hidden, using the setHidden: method.

这篇关于NSView鼠标跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆