• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
runModalSession handling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

runModalSession handling


  • Subject: runModalSession handling
  • From: Tom Doan <email@hidden>
  • Date: Thu, 05 Apr 2018 17:27:09 -0500
  • Priority: normal

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: runModalSession handling
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Avoiding link conflicts with a static library
  • Next by Date: Re: problem getting CALayer to draw an image
  • Previous by thread: Re: problem getting CALayer to draw an image
  • Next by thread: Re: runModalSession handling
  • Index(es):
    • Date
    • Thread