NSTextField inside NSPopover is not key until mouse click

隐身守侯 提交于 2019-12-12 10:09:04

问题


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

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.

I've tried things like invoking NSWindow's makeFirstResponder upon popoverDidShow:. There was no change in behavior from this. Anyone have any ideas here?


回答1:


My guess is you need to make your app active; try calling

[NSApp activateIgnoringOtherApps:YES];

when you show your popover.

Edit: Of course, I could be wrong. This is all just off the top of my head.



来源:https://stackoverflow.com/questions/10705369/nstextfield-inside-nspopover-is-not-key-until-mouse-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!