Re: Leaving Modal Loop with Sheets
Re: Leaving Modal Loop with Sheets
- Subject: Re: Leaving Modal Loop with Sheets
- From: mw <email@hidden>
- Date: Mon, 07 Oct 2002 06:40:50 -0400
Hey, thanks! That did it! Now why didn't I think of that...
mw
On 10/7/02 1:53 AM, "Tony S. Wu" <email@hidden> wrote:
>
> - (IBAction)closeWindow:(id)sender
>
> {
>
> // Hide the sheet
>
> [[self window] orderOut:sender];
>
>
>
> // Return to normal event handling
>
> [NSApp endSheet:sender];
>
> }
>
>
The proper way to end a sheet, I believe, would be:
>
>
// you did this part right
>
[[self window] orderOut: sender];
>
>
// you did this part wrong
>
[NSApp endSheet: [self window] returnCode: 1];
>
>
Hope this helps.
>
>
Tony S. Wu
>
email@hidden
>
>
"Nope, this world ain't perfect. But at least I know it's not because of
>
me."
>
>
>
mw at email@hidden wrote:
>
>
> Hey again everyone,
>
>
>
> I have a custom sheet (from a nib) that drops a-okay, and has all of its
>
> events handled okay by its window controller. Whenever the sheet is
>
> dismissed, it seems to retain the modal loop that the app was in for the
>
> sheet, so it beeps whenever anything is clicked and the table stops working
>
> completely.
>
>
>
> Here is the call I am using to show the sheet:
>
>
>
> [NSApp beginSheet:[self window]
>
> modalForWindow:window
>
> modalDelegate:self
>
> didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
>
> contextInfo:nil];
>
>
>
> (Remember, this is in a subclass of NSWindowController that controls the
>
> sheet window).
>
>
>
> Here is the implimentation of the sheetDidEnd: method...
>
>
>
> - (void)sheetDidEnd: (NSWindow *)sheet returnCode: (int)returnCode
>
> contextInfo: (void *)contextInfo
>
> {
>
> NSLog(@"Alert sheet ended.");
>
> [NSApp stopModal];
>
> }
>
>
>
> And when the OK button is pressed in the sheet, this function is called:
>
>
>
> - (IBAction)closeWindow:(id)sender
>
> {
>
> // Hide the sheet
>
> [[self window] orderOut:sender];
>
>
>
> // Return to normal event handling
>
> [NSApp endSheet:sender];
>
> }
>
>
>
> But again, it never seems to leave the modal loop that the sheet was in
>
> after the sheet is dismissed. Am I missing something in my code somewhere?
>
>
>
> -- mw
>
> _______________________________________________
>
> 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.
_______________________________________________
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.