Re: progress bar on sheet
Re: progress bar on sheet
- Subject: Re: progress bar on sheet
- From: Joannou Ng <email@hidden>
- Date: Sun, 10 Apr 2005 16:34:59 -0400
Hi Chuck,
The reason your progressIndicator isn't animating is because your time consuming task is freezing the user interface.
Use NSThread's
detachNewThreadSelector:toTarget:withObject:<x-tad-bigger>
</x-tad-bigger>http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSThread.html
Then, when your time consuming task is done, call NSObject's
performSelectorOnMainThread:withObject:waitUntilDone:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSObject.html
Cheers, Joannou.
On 2005 Apr 10, at 15:45, Chuck Soper wrote:
Hello,
I'm trying to display a custom sheet with Yes/No buttons and a indeterminate progress indicator. When the user clicks Yes I need to start animating the indicator and start a time consuming task. When the task finishes I'd like to display an NSRunAlertPanel then make the sheet go away. All of this works great without the progress indicator.
I confirmed that the indicator is connecting properly with this line:
NSLog(@"maxValue = %d", (int) [doTaskProgress maxValue]);
Also, I confirmed that the NSProgressIndicator instance in IB is indeterminate.
My source is below. Does anyone know how I can get this working? I think that the fact that the sheet is modal is preventing the progress bar from updating.
Chuck
// from interface
IBOutlet NSPanel * doTaskSheet;
IBOutlet NSProgressIndicator *doTaskProgress;
// from implementation
- (IBAction)doTaskYes:(id)sender;
{
doingTask = TRUE;
[NSApp endSheet:doTaskSheet];
}
- (IBAction)doTaskNo:(id)sender;
{
[NSApp endSheet:doTaskSheet];
}
- (void)askToDoTaskSheetDidEnd:(NSWindow *)sheet
returnCode: (int)returnCode
contextInfo: (void *)contextInfo
{
if (doingTask) {
[doTaskProgress displayIfNeeded];
[doTaskProgress startAnimation:nil];
//do time consuming task then display alert then remove sheet
[self doTimeConsumingTask];
NSRunAlertPanel(statusString, resultString, @"OK", nil, nil);
[doTaskProgress stopAnimation:nil];
}
doingTask = FALSE;
[sheet orderOut:self];
}
//display the sheet and ask user what to do
- (void)askToDoTaskSheet
{
doingTask = FALSE;
[NSApp beginSheet: doTaskSheet
modalForWindow: mainWindow
modalDelegate: self
didEndSelector:
@selector(askToDoTaskSheetDidEnd:returnCode:contextInfo:)
contextInfo: nil];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden