• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSPanel as Sheet and controlling the run loop
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: NSPanel as Sheet and controlling the run loop
      • From: Vincent Coetzee <email@hidden>
References: 
 >NSPanel as Sheet and controlling the run loop (From: "Alexander F. Hartner" <email@hidden>)

  • Prev by Date: Re: Send Email with "deliverMessage"
  • Next by Date: Re: Drawer Edges Change
  • Previous by thread: Re: NSPanel as Sheet and controlling the run loop
  • Next by thread: Re: NSPanel as Sheet and controlling the run loop
  • Index(es):
    • Date
    • Thread