I'm writing a multi-document application using Cocoa. The user must enter a password when opening a document. After a certain amount of time without activities on a document the user is once again required to enter the password.
Right now I'm using NSAplication
's beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
to show the password prompt in a custom sheet. While it works it has the unfortunate side-effect of the window being brought to front and given focus even if another document is being worked on at the time. It is only problematic if my application is in front.
Is there a way to prevent opening a sheet from snatching focus if its parent window is not active?