问题描述
我有一个通过与NSStatusItem交互显示的NSPopover.我已经在此博客中写了关于在这种情况下甚至可以进行输入所需的骇客操作: http://blog.brokenrobotllc.com/using-nspopover-with-nsstatusitem
I've got an NSPopover that is shown from interaction with an NSStatusItem. I've blogged about the hacks I needed to do to make input even possible in this situation here: http://blog.brokenrobotllc.com/using-nspopover-with-nsstatusitem
我在NSPopover的内容视图中有一个NSTextField.当我打开NSPopover时,NSTextField就像键一样显示(光标闪烁).但是,键入时,没有任何显示.如果我在该字段中单击鼠标,那么输入将在那里开始显示.
I have an NSTextField inside the NSPopover's content view. When I open the NSPopover, the NSTextField appears as if it is key (the cursor blinks). But, when typing, nothing shows up. If I click the mouse in the field, my input starts showing up there.
我已经尝试过诸如在popoverDidShow:上调用NSWindow的makeFirstResponder之类的事情.行为没有改变.有人在这里有想法吗?
I've tried things like invoking NSWindow's makeFirstResponder upon popoverDidShow:. There was no change in behavior from this. Anyone have any ideas here?
推荐答案
我的猜测是,您需要使您的应用程序处于活动状态;尝试致电
My guess is you need to make your app active; try calling
[NSApp activateIgnoringOtherApps:YES];
显示弹出窗口时.
当然,我可能是错的.这一切都在我的头上.
Of course, I could be wrong. This is all just off the top of my head.
这篇关于直到单击鼠标,NSPopover中的NSTextField才是关键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!