views:

106

answers:

1

I have an OS X prefpane that calls a NSAlert sheet with:

 [alert beginSheetModalForWindow:[[self mainView] window] modalDelegate:self didEndSelector:@selector(unsavedChangesAlertDidEnd:returnCode:contextInfo:) contextInfo:nil];

Which shows the alert sheet attached to the System Preferences application fine, but when I click the sheet's OK button, it closes and doesn't return focus to System Preferences. Any ideas?

A: 

Try sending that window a -makeKeyAndOrderFront: message at the end of your -unsavedChangesAlertDidEnd:returnCode:contextInfo: method.

NSResponder
For some reason, my window doesn't have that selector. I'm calling the window from my prefpane like: [[self mainView] window]
K_T
timmerk: All windows (i.e., all instances of NSWindow or any subclass thereof) respond to that selector. It would help if you posted the actual exception message.
Peter Hosey
Peter: that's what I thought, but Xcode keeps saying window might not respond to it. There was no exception, but I figured out the problem - inside my unsavedChangesAlertDidEnd method, I launch a background app using NSWorkspace which caused the loss of focus. Thanks all!
K_T