FROM : Kyle Hammond
DATE : Sat Apr 16 17:58:43 2005
Hi,
Remove that call to [NSApp stopModal] and only the dlgBrowse will go
away when it's done. There's no need to do a sheet or any other weird
contortions to get modal on modal windows working. You can have many
levels of modal windows all going if you really need to; it's not the
greatest design to force the user through many levels of modal windows,
but there's nothing in Cocoa preventing you from doing it.
It's not a Cocoa bug, it's a programming error.
Longer explanation: Your call "returnCode = [NSApp
runModalForWindow:dlgBrowse];" doesn't come back until the dlgBrowse
window is done. In other words, some other code (the controller for
dlgBrowse probably) has already stopped the modal loop for dlgBrowse.
Then your code continues on to remove the dlgBrowse from the screen
which is fine, although I generally put that code into the OK or Cancel
handler for the dlgBrowse itself. Then you call [ NSApp stopModal ]
which stops your ORIGINAL modal window that started the dlgBrowse.
Thus both modal windows disappear once the dlgBrowse is done.
Hope that helps.
Kyle
> Op 11-apr-05 om 20:46 heeft Luc Vandal het volgende geschreven:
>
>> Hi,
>>
>> I have a modal window that displays another modal window:
>>
>> int returnCode;
>> returnCode = [NSApp runModalForWindow:dlgBrowse];
>> [dlgBrowse orderOut:self];
>> [NSApp stopModal];
>>
>> The problem is that when I click on Ok or Cancel on the 2nd window
>> (which was opened by the 1st modal window), stopModalWithCode will
>> close both windows at the same time. So I tried this:
>
> I think this is a known bug (well, I submitted a bug report but no
> action). I had to do some weird workaround where I used a sheet for the
> second dialog. Unsavoury but it worked for me.
---------------------
Kyle Hammond
kyle.<email_removed>
<http://www.snowmintcs.com/> - personal productivity software
DATE : Sat Apr 16 17:58:43 2005
Hi,
Remove that call to [NSApp stopModal] and only the dlgBrowse will go
away when it's done. There's no need to do a sheet or any other weird
contortions to get modal on modal windows working. You can have many
levels of modal windows all going if you really need to; it's not the
greatest design to force the user through many levels of modal windows,
but there's nothing in Cocoa preventing you from doing it.
It's not a Cocoa bug, it's a programming error.
Longer explanation: Your call "returnCode = [NSApp
runModalForWindow:dlgBrowse];" doesn't come back until the dlgBrowse
window is done. In other words, some other code (the controller for
dlgBrowse probably) has already stopped the modal loop for dlgBrowse.
Then your code continues on to remove the dlgBrowse from the screen
which is fine, although I generally put that code into the OK or Cancel
handler for the dlgBrowse itself. Then you call [ NSApp stopModal ]
which stops your ORIGINAL modal window that started the dlgBrowse.
Thus both modal windows disappear once the dlgBrowse is done.
Hope that helps.
Kyle
> Op 11-apr-05 om 20:46 heeft Luc Vandal het volgende geschreven:
>
>> Hi,
>>
>> I have a modal window that displays another modal window:
>>
>> int returnCode;
>> returnCode = [NSApp runModalForWindow:dlgBrowse];
>> [dlgBrowse orderOut:self];
>> [NSApp stopModal];
>>
>> The problem is that when I click on Ok or Cancel on the 2nd window
>> (which was opened by the 1st modal window), stopModalWithCode will
>> close both windows at the same time. So I tried this:
>
> I think this is a known bug (well, I submitted a bug report but no
> action). I had to do some weird workaround where I used a sheet for the
> second dialog. Unsavoury but it worked for me.
---------------------
Kyle Hammond
kyle.<email_removed>
<http://www.snowmintcs.com/> - personal productivity software
| Related mails | Author | Date |
|---|---|---|
| Luc Vandal | Apr 11, 20:46 | |
| Steven Kramer | Apr 16, 14:49 | |
| Kyle Hammond | Apr 16, 17:58 | |
| Steven Kramer | Apr 17, 13:33 |






Cocoa mail archive

