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

标签 objective-c cocoa nswindow growl

我正在编写一个通知系统,就像 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/

相关文章:

macos - 如何将自定义 NSView 添加到 Window

xcode - OSX HUD 面板 全透明

cocoa - 不 initWithWindowNibName 设置窗口字段

ios - MFMailComposeViewController 不工作

objective-c - 如何从 KeyChain 获取代理主机的用户名?

iphone - 将 CLLocation 转换为 CLLocationDegrees

objective-c - 在 NSButton 子类中绘制文本 - 定位

objective-c - Cocoa 状态栏中的进度微调器

objective-c - 以编程方式设置 UIView 的自定义类?

cocoa - 如何反转 [NSWindow Zoom] 方法调用?