我有一个这样创建的 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)