NSTextField dentro de NSPopover no es clave hasta que haga clic con el mouse
Frecuentes
Visto 983 veces
2
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 Respuestas
5
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 objective-c macos cocoa nswindow nspopover or haz tu propia pregunta.
Entonces el
NSTextField
is inside a custom view (that is loaded by theNSViewController
subclass)? I have this with anNSTextView
incrustado en unNSScrollView
(programatically created) and don't have this issue and I don't need to any tricks to make theNSTextView
the first responder. - trojanfoe