• 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
Re: Supressing NSAlertPanel with time litmit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Supressing NSAlertPanel with time litmit


  • Subject: Re: Supressing NSAlertPanel with time litmit
  • From: Jerry Krinock <email@hidden>
  • Date: Wed, 12 Sep 2007 21:36:22 -0700


On 2007 Sep, 12, at 21:12, Jajati Sahu wrote:

I have created a NSGetCriticalAlertPanel and run it by runModalForWindow:
method of NSApp. I have one "OK" button in the alert. Now I want to close
the alert panel after some delay (suppose 5 seconds) if "OK" button is not
clicked within that time period. As it is runModal I am not able to close
the alert before "OK" button clicked.




Is there any way to close the runModal NSAlertPanel giving time constraint.

Those modal sessions can be tricky, and easily crashed. I'm not sure if this will work, but try scheduling a 5-second NSTimer targetting the following method. The symbol _modalSession is an instance variable, the NSModalSession that you got when you started the modal session.


- (void)endModalSession {
    if (_modalSession) {
        int response = [NSApp runModalSession:_modalSession] ;
        BOOL done = (response != NSRunContinuesResponse) ;
        if (!done) {
            // if() since re-sending -stopModal might cause a crash
            [NSApp stopModal] ;
        }
        [NSApp endModalSession:_modalSession] ;

        _modalSession = 0 ;
    }
}


_______________________________________________

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


References: 
 >Supressing NSAlertPanel with time litmit (From: "Jajati Sahu" <email@hidden>)

  • Prev by Date: Supressing NSAlertPanel with time litmit
  • Next by Date: overriding NSObject initWithCoder/encodeWithCoder category?
  • Previous by thread: Supressing NSAlertPanel with time litmit
  • Next by thread: Re: Supressing NSAlertPanel with time litmit
  • Index(es):
    • Date
    • Thread