NSSavePanel, background-only app, "Replace?" alert ordering
NSSavePanel, background-only app, "Replace?" alert ordering
- Subject: NSSavePanel, background-only app, "Replace?" alert ordering
- From: Dave Hersey <email@hidden>
- Date: Sat, 07 Feb 2004 10:55:22 -0500
Sorry, the code for this should have been:
Hi,
I'm having a problem with NSSavePanel from a background-only app with an
NSStatusItem. The app in question may encounter data errors during data
processing, and I want to allow the user to save an error report rather than
cough up a dialog with a bunch of gory details that they need to scribble
down correctly.
This mostly works, but in the case where the destination file already
exists, the NSSavePanel "Replace file?" alert comes up *behind* the Save
panel, making it hard or impossible to notice.
If I click on the Save panel or click on the menu item for my app's status
item, the "Replace?" alert does comes forward.
How can I make the "Replace?" alert appear in front of the "Save" panel?
The following code demonstrates the problem if you call it twice and try to
save the file in the same location. I'm guessing that it needs to run in a
background-only application, possibly with an NSStatusItem, for the problem
to occur.
Thanks,
- Dave
// Called as: [self reportError: @"Error detail."];
- (void) reportError: (NSString *) errorDetail
{
CFOptionFlags responseFlags;
CFUserNotificationDisplayAlert(0, kCFUserNotificationCautionAlertLevel,
nil, nil, nil,
(CFStringRef) @"An error occurred.",
(CFStringRef) @"Click \"Save Report\" to save an error report.",
(CFStringRef) @"Save Report",
(CFStringRef) @"Cancel",
nil, &responseFlags);
if ((responseFlags & 0x03) == kCFUserNotificationDefaultResponse)
{
NSSavePanel *savePanel = [NSSavePanel savePanel];
int runResult;
[savePanel makeKeyAndOrderFront: self];
bt = [savePanel runModalForDirectory: @"/" file: @"Error Report.txt"];
if (bt == NSOKButton)
{
// Save the report.
NSString *newFileString, *appendFileString;
newFileString =
[[NSString alloc] initWithFormat: @"echo \'%@\' > \'%@\'",
errorDetail, [savePanel filename]];
system([newFileString UTF8String]);
[newFileString release];
}
}
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.