Re: [NEWBIE] Sheets problem
Re: [NEWBIE] Sheets problem
- Subject: Re: [NEWBIE] Sheets problem
- From: Brian Webster <email@hidden>
- Date: Mon, 25 Jun 2001 23:22:24 -0500
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