1

我有一个这样创建的 NSStatusItem:

statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[statusItem setTitle:@"DS"];
[statusItem setHighlightMode:YES];
[statusItem setAction:@selector(StatusClicked:)];
[statusItem setTarget:self]; 

我也有一个带有自定义视图的弹出窗口。在视图中我有文本字段: http: //d.pr/i/CWbr

我的弹出框显示如下:

- (void)StatusClicked:(id)sender {
    [self.popover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxYEdge];
}

从调试器中我了解到这sender是一个NSStatusBarButton类的实例。

问题是,当弹出窗口弹出我无法在文本字段中输入时,它似乎处于非活动状态:http ://d.pr/i/q18U

该按钮正在工作。

我认为这个问题出在我传递给ofView:. 我试图将其更改为窗口上的控件,如下所示:

 [self.popover showRelativeToRect:[sender bounds] ofView:self.postText preferredEdge:NSMaxYEdge];

并且文本字段变得活跃(http://d.pr/i/DmTz),但我不知道为什么这会有所帮助。

为什么我的弹出框文本框在从菜单中弹出时变为非活动状态?为什么按钮有效?如何使文本字段处于活动状态?

PS我的应用是Application is agent (UIElement)

4

1 回答 1

0

写完问题后,我认为这可能与关键窗口有关。所以我搜索了这个连接,发现了这个问题:Not able to edit NSTextField on NSPopover even if Editable behavior is set

这完美地回答了我的问题。它似乎是一个错误。

于 2013-03-24T14:05:16.977 回答