gpt4 book ai didi

objective-c - 类似 nswindow 级别的 growl 通知

转载 作者:行者123 更新时间:2023-12-03 17:43:23 25 4
gpt4 key购买 nike

我正在编写一个通知系统,就像 growl 一样。通知是一个窗口,其级别设置为 NSModalPanelWindowLevel。唯一的问题是,我在该窗口中有一个按钮,当用户想要单击该按钮时,他/她必须单击两次。但是,例如,在 growl 中,无论您打开哪个窗口,您只需单击通知,它就会记录一次单击。那么是不是水平问题呢?如果是这样,我应该将其设置为什么?谢谢

最佳答案

在构成窗口 View 内容的自定义控件中,您可能希望覆盖 NSView-acceptsFirstMouse:返回YES的方法:

Discussion

The receiver can either return a value unconditionally or use the location of theEvent to determine whether or not it wants the event. The default implementation ignores theEvent and returns NO.

Override this method in a subclass to allow instances to respond to click-through. This allows the user to click on a view in an inactive window, activating the view with one click, instead of clicking first to make the window active and then clicking the view. Most view objects refuse a click-through attempt, so the event simply activates the window. Many control objects, however, such as instances of NSButton and NSSlider, do accept them, so the user can immediately manipulate the control without having to release the mouse button.

关于objective-c - 类似 nswindow 级别的 growl 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5656266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com