NSTextField dentro de NSPopover no es clave hasta que haga clic con el mouse

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?

preguntado el 22 de mayo de 12 a las 16:05

Entonces el NSTextField is inside a custom view (that is loaded by the NSViewController subclass)? I have this with an NSTextView incrustado en un NSScrollView (programatically created) and don't have this issue and I don't need to any tricks to make the NSTextView the first responder. -

1 Respuestas

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.

contestado el 22 de mayo de 12 a las 17:05

Man you made my day. Thanks! Exactly what I needed. - Aliaksandr Bialiauski

rápido: NSApplication.shared.activate(ignoringOtherApps: true) - Justin Oroz

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.