NSAlert Sheet Not Having Focus
EDITED TO ADD: Several months later, I ran into this same bug again!
I had an issue where if I used
to put up an
NSAlert as a sheet inside a window, and I was not running on the main thread, the sheet would not have focus. I’m not sure exactly why, but this solution worked for me: Put the call to
beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo: inside another method,
showMyAlert, then use
performSelectorOnMainThread:withObject:waitUntilDone: to make sure
showMyAlert is called on the main thread.
Strangely, if i used
runModal to display the NSAlert as a separate modal window, it would have focus.
The whole incident feels funny to me. I suspect there may be some deeper issue at work that I am not aware of. When I have time to investigate further I shall update this post. Unfortunately I don’t have time to look into ‘solved’ bugs today.