【发布时间】:2010-12-23 21:03:03
【问题描述】:
具体来说,它在文本字段焦点方面的行为不一致。
我有一个 LSUIElement 弹出状态菜单。在该菜单中有一个包含文本字段的视图。文本字段必须是可选择的——不一定是默认选择,但可以选择。
当状态项被点击时触发
[NSApp activateIgnoringOtherApps:YES];
它工作,大约一半的时间。* 状态菜单的另一半似乎认为自己“在后台”,即使单击它也不会让我将注意力集中在文本字段上。 (我知道状态项点击触发器正在触发 b/c 上面有一个 NSLog。)
这是 Apple 处理这些状态项的方式中的错误,还是我错误地处理了 activateIgnoringOtherApps?
*事实上,它似乎只是在另一个应用程序激活后第一次失败。之后就可以正常使用了。
完整的sn-p:
-(void)statusItemClicked:(id)sender {
//show the popup menu associated with the status item.
[statusItem popUpStatusItemMenu:statusMenu];
//activate *after* showing the popup menu to obtain focus for the text field.
[NSApp activateIgnoringOtherApps:YES];
}
【问题讨论】:
标签: cocoa statusbar nsstatusitem