• 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: NSAlert synchronous sheet?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSAlert synchronous sheet?


  • Subject: Re: NSAlert synchronous sheet?
  • From: Hamish Allan <email@hidden>
  • Date: Wed, 23 Mar 2005 02:27:28 +0000

In case nobody comes up with a better solution, this one works:

- (BOOL)windowShouldClose:(id)sender
{
if ([[self windowController] moreThanOneTabShowing])
{
NSAlert *alert = [NSAlert
alertWithMessageText:@"You have multiple tabs open"
defaultButton:@"Close All Tabs"
alternateButton:@"Cancel"
otherButton:nil
informativeTextWithFormat:
@"Do you want to close all of the tabs in this window?"];
[alert beginSheetModalForWindow:self
modalDelegate:self
didEndSelector:@selector(multipleTabsAlertDidEnd:returnCode: contextInfo:)
contextInfo:(void *)sender];
return NO;
}
else
return YES;
}


- (void)multipleTabsAlertDidEnd:(NSAlert *)alert
	returnCode:(int)returnCode contextInfo:(void *)sender
{
	if (returnCode == NSAlertDefaultReturn)
		[self close];
}

I don't like it: I would have used performClose: instead of shouldWindowClose: except that it isn't called when the close button is clicked (only when such a click is to be programmatically simulated, such as from a menu item).

NB all of this might be non-standard behaviour as this is part of a SIMBL plugin for Safari. If anyone is interested in this functionality (which is the deal-maker for tabbed browsing as far as I am concerned) please let me know and I'll make it available.

Best wishes,
Hamish

On Mar 22, 2005, at 23:26, Hamish Allan wrote:

Hi,

NSAlert seems to provide two ways to run:

– runModal, for blocking application-modal dialogs, or
– beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:, for non-blocking document-modal sheets.


I want a blocking document-modal sheet, for an "Are you sure" type of question in response to a windowShouldClose:, but I can see that this would tie up the run loop and prevent other document windows from functioning. However, it's not clear to me how to implement this asychronously. Can anybody point me in the right direction?

Thanks,
Hamish


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >NSAlert synchronous sheet? (From: Hamish Allan <email@hidden>)

  • Prev by Date: Memory leak by pragmatically updating bound NSMutableArray?
  • Next by Date: RE: [OT] How to be a real programmer
  • Previous by thread: NSAlert synchronous sheet?
  • Next by thread: authopen wrapper?
  • Index(es):
    • Date
    • Thread