This question is answer Not able to edit NSTextField on NSPopover even if Editable behavior is set,但因为 StackOverflow 不允许您发表评论,除非您有一定的声誉,我不得不创建另一个线程。我完全按照答案中的解释做了,没有运气。这是使用 Xcode 5 的 10.9。我将 NSWindow+CanBecomeKeyWindow.m 添加到构建设置中。因为这是一个只有状态栏的应用程序,所以我在 plist 中将 Application is Agent 设置为 YES 并且没有使用应用程序中的任何窗口。任何想法如何与小牛队实现这一点?
NSWindow+canBecomeKeyWindow.h
@interface NSWindow (canBecomeKeyWindow)
@end
NSWindow+canBecomeKeyWindow.m
@implementation NSWindow (canBecomeKeyWindow)
//This is to fix a bug with 10.7 where an NSPopover with a text field cannot be edited if its parent window won't become key
//The pragma statements disable the corresponding warning for overriding an already-implemented method
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
- (BOOL)canBecomeKeyWindow
{
return YES;
}
#pragma clang diagnostic pop
@end