• 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: [NEWBIE] Sheets problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NEWBIE] Sheets problem


  • Subject: Re: [NEWBIE] Sheets problem
  • From: j o a r <email@hidden>
  • Date: Tue, 26 Jun 2001 21:06:58 +0200

Hi,

But what if you don't know that you will put up a sheet? In my case I am comparing two large arrays, in rare cases I would need to ask the user a question - but not nearly every time. If I can't run modal for application then I need to write a lot more code, or loop over the arrays again, to handle this case. It feels like a waste of time when it would be so easy to solve if the sheet could simply halt the execution when it is displayed.

Sure I could use a standard dialog, but sheets are prettier...

Regards,

j o a r

On tisdag, juni 26, 2001, at 06:22 , Brian Webster wrote:

On Monday, June 25, 2001, at 07:45 PM, cocoa-dev-
email@hidden wrote:

As I've said in another post, using only beginSheet, endSheet, and
orderOut, everything works properly.
But now, the problem is that the function which calls beginSheet: should
return the sum of the int values of 2 text fields, and so should wait
until the sheet is closed, i.e. the user has validated the values that
he has entered into the fields.
Is there a way to do "wait until the sheet is closed" without
runModalForWindow ?

Oh, I see what you want now. So do you have something along these lines?

-(void)userActionThatNeedsToUseSheet:(id)sender
{
int inputValue;

//do some stuff before running sheet
inputValue = [self runSheetToGetValues];
//do something with input value
}

-(int)runSheetToGetValues
{
[NSApp beginSheet:sheet ... etc.];
return [textField1 intValue] + [textField2 intValue];
}

-(void)userActionThatEndsSheet:(id)sender
{
[NSApp endSheet:sheet];
}

If you do, and you really want to use a sheet, then this method won't work. You'll need to design it a little differently and put off handling the input values until the user dismisses the sheet, like so:

-(void)userActionThatNeedsToUseSheet:(id)sender
{
//do some stuff before running sheet
[self runSheetToGetValues];
}

-(void)runSheetToGetValues
{
[NSApp beginSheet:sheet ...];
}

-(void)userActionThatEndsSheet:(id)sender
{
int inputValue = [textField1 intValue] + [textField2 intValue];
[NSApp endSheet:sheet];
//do something with input value
}

Whatever code it is that actually does something with the input value needs to be put off until after the sheet is dismissed, it's not just a simple stack of function calls, since the user can do any number of things between the sheet starting and being dismissed.

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev


  • Follow-Ups:
    • Re: [NEWBIE] Sheets problem
      • From: Matthew Formica <email@hidden>
References: 
 >Re: [NEWBIE] Sheets problem (From: Brian Webster <email@hidden>)

  • Prev by Date: Re: Document object retain and release
  • Next by Date: Reading plists
  • Previous by thread: Re: [NEWBIE] Sheets problem
  • Next by thread: Re: [NEWBIE] Sheets problem
  • Index(es):
    • Date
    • Thread