Re: Killing myself from a modal dialog
Re: Killing myself from a modal dialog
- Subject: Re: Killing myself from a modal dialog
- From: Jerry LeVan <email@hidden>
- Date: Fri, 08 Nov 2002 09:55:04 -0500
Matt,
Thank you for your comments. I have only been about this for a couple of
weeks...
However in my case modality is important. The application is single windowed
and at the point of raising the modal window a lot of implied context has
been generated, to immediately continue from this point would be a disaster,
(the context would be lost) if the requested information from the window was
not available.
It might be possible to restructure the code, but it is not clear to me that
doing so would add to the clarity of the algorithm.
The answer to my original question "How can I quit an app from a modal
dialog" was answered by placing
[NSApp stopModal];
[NSApp endSheet: remoteWindow]; //required!
[remoteWindow orderOut: self];
[NSApp terminate:self];
Into the quit button. The OK button action basically did an [NSApp
stopModal] after recording the info the user selected.
Everything seems to be working Ok.
Thanks,
Jerry
>
>Like to kill the app when the quit button is pressed. The following
>
>code
>
>Shows the dialog and when the quit button is pressed, all I get is a
>
>beep
>
>
>
> [NSApp beginSheet: remoteWindow
>
> modalForWindow: [NSApp mainWindow]
>
> modalDelegate: nil
>
> didEndSelector: nil
>
> contextInfo: nil];
>
> [NSApp runModalForWindow: remoteWindow];
// sheet is up here...
[NSApp endSheet: remoteWindow]; //required!
[remoteWindow orderOut: self];
>
There's your mistake. Your problem is that you have not grasped the
>
basics of sheet usage. See the other note I just sent ("end of sheet and
>
re-activationg window"). As the docs say, "Because sheets are document
>
modal, these calls return immediately after presenting a sheet. Callback
>
methods are used to let your application know when the user dismisses a
>
sheet." You are wrong to block using runModalForWindow. After beginSheet
>
your method must exit; the app continues to run, and the user's actions
>
must then be caught by some other routine. The docs do contain an
>
example of doing it the way you do here (in the CascadingSheets doc),
>
but that example is simply wrong. m.
>
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt
_______________________________________________
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.