Skip navigation.
 
mlprogress bar on sheet
FROM : Chuck Soper
DATE : Sun Apr 10 21:45:23 2005

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];

}

Related mailsAuthorDate
mlprogress bar on sheet Chuck Soper Apr 10, 21:45
mlRe: progress bar on sheet Joannou Ng Apr 10, 22:34
mlRe: progress bar on sheet Shawn Erickson Apr 10, 22:48
mlRe: progress bar on sheet Chuck Soper Apr 10, 23:05
mlRe: progress bar on sheet Hamish Allan Apr 11, 00:25
mlRe: progress bar on sheet Chuck Soper Apr 11, 02:09