I've created a custom subclass of NSControl
which accepts a small amount of text. I'm using the window's field editor for any editing purposes (just like how NSTextField
does). When I lose first responder status, I'd obviously like to send a -commitEditing:
message, but if you're well-versed in the area of OS X's text system, you know that a -resignFirstResponder
message is sent to the control before appointing the field editor as the new first responder.
So I was thinking that if I could find out whether the field editor is to be the new first responder when the -resignFirstResponder
method is called, I could make sure -commitEditing:
isn't called.
With that said, is there a way to find out which object will become the new first responder?
subclass NSApplication That way you can catch preprocess NSEvents, collect the information you need, and then your NSControl subclass can retrieve that information.
In my case, I use this method to avoid dangling field editors in my very large multi-screen UI.
in main(), instantiate NSApplicationEventCatcher first,
before calling NSApplicationMain()
now, here's some of the checking that I do in NSApplicationEventCatcher sendEvent override.
However, this is only one small part of that solution.
And here is a related part: