NSTrackingArea 和性能
我有一个 NSTrackingArea 来确定是否应该在我的视图中显示关闭“按钮”。我想显示翻转图像。
更好的是,
- 实际上使用一个按钮(作为子视图)而不是绘制我自己的东西,然后向按钮添加另一个跟踪区域,然后显示翻转图像。
- 使用 第二 NSTrackingArea 来确定何时鼠标位于关闭按钮的顶部,因此我可以显示翻转图像。
我个人认为第二个更容易,我唯一需要做的额外的事情就是按钮为我做的就是实现点击操作。
I have a NSTrackingArea to determine whether I should show a close "button" in my view. I would like to show a rollover image.
What is better,
- Actually using a button ( as a subview ) instead of drawing my own thing, then adding another tracking area to the button and then showing the rollover image..
- Using a second NSTrackingArea to determine when the mouse is on top of the close button so I can show the rollover image.
I personally think the second one is easier, the only thing that I would have to do extra what the button would do for me is implementing a click action.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用对您来说最容易实施的方法。两者都不太可能导致任何性能问题(
NSTrackingArea
已经高度优化。)Use whichever approach is simplest for you to implement. It is extremely unlikely that either will cause any performance problems (
NSTrackingArea
is already highly optimized.)