Re: runModalSession handling

2018-04-05 Thread Quincey Morris
On Apr 5, 2018, at 15:27 , Tom Doan  wrote:
> 
> I checked and none of my stopModalWithCodes are being fired, so the result 
> code has to be coming off the system dialog. I did a kludge where I used 100 
> and 101 for my own stop codes, and continued on 0 and 1, and that seemed to 
> work around this

This does sound like a bug, but it’s hard to know. Using different stop codes 
seems like a rational way to approach the problem.

Other possibilities you might investigate:

1. Close the modal window before using the NSOpenPanel, then reopen it with a 
new modal session afterwards.

2. Display the NSOpenPanel as a sheet on the modal window, rather than a 
separate window.

Is Carbon involved here in any way? This code looks like it was Carbon once, at 
least.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


runModalSession handling

2018-04-05 Thread Tom Doan
Based upon a recommendation that I found, I changed up code from running a 
modal dialog to use 
beginModalSessionForWindow and runModalSession. Unfortunately, if I run an 
NSOpenPanel from within this 
(used for a browse for a target directory), runModalSession for *my* dialog 
returns the 0 or 1 off the open panel 
as soon as that closes, thus (with my expected handling) closing my dialog as 
well. I checked and none of my 
stopModalWithCodes are being fired, so the result code has to be coming off the 
system dialog. I did a kludge 
where I used 100 and 101 for my own stop codes, and continued on 0 and 1, and 
that seemed to work around 
this, but I would really like to understand what is wrong with this setup.

Best regards,

Tom Doan
---
1560 Sherman Ave #1029
Evanston, IL 60201
USA




#if 0
//
//  Original code
//
itsRC = (LOGICAL) ([NSApp runModalForWindow:itsDialog->GetDlgWnd()]);
#else
//
//  Code which gives main loop time
//
NSModalSession session = [NSApp 
beginModalSessionForWindow:itsDialog->GetDlgWnd()];
int result = NSModalResponseContinue;

while (result == NSModalResponseContinue)
{
//run the modal session
//once the modal window finishes, it will return a different 
result and break out of the loop
result = [NSApp runModalSession:session];

//this gives the main run loop some time so your other code 
processes
[[NSRunLoop currentRunLoop] 
limitDateForMode:NSDefaultRunLoopMode];

//do some other non-intensive task if necessary
}
[NSApp endModalSession:session];
itsRC = (LOGICAL) (result);
#endif



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com