Re: NSPanel as Sheet and controlling the run loop
Re: NSPanel as Sheet and controlling the run loop
- Subject: Re: NSPanel as Sheet and controlling the run loop
- From: Larry Fransson <email@hidden>
- Date: Wed, 7 Apr 2004 10:34:54 -0700
I'm sure you'd figure it out eventually like I did. But to help you
along, here's some code that I have used. It opens a window as a sheet
(I'm sure a panel will work just fine as well) with a progress bar and
some descriptive text. It runs while some file processing is going on,
and then closes when the process is finished.
[NSApp beginSheet:indexWindow
modalForWindow:mainWindow
modalDelegate:nil
didEndSelector:nil
contextInfo:nil];
session = [NSApp beginModalSessionForWindow:indexWindow];
[indexProgressText setStringValue:@"Reading the new data
file..."];
[indexProgressBar setUsesThreadedAnimation:YES];
[indexProgressBar startAnimation:self];
[NSApp runModalSession:session];
dataString = [[NSString alloc] initWithContentsOfFile:[sheet
filename]];
[indexProgressBar setIndeterminate:FALSE];
[indexProgressBar setMinValue:0.0];
[indexProgressBar setMaxValue:(double)[dataString length]];
[self indexDataFromString]; // This method also updates the
progress bar and
// the text in the progress window.
// Processing finished - close the sheet
[NSApp endModalSession:session];
[NSApp endSheet:indexWindow];
[indexWindow orderOut:self];
I don't remember now what happened before I put the "orderOut:" in
there at the end. I only remember that it didn't work exactly right
until I did.
Larry Fransson
Seattle, WA
_______________________________________________
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.