• 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
Application modal sheets
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Application modal sheets


  • Subject: Application modal sheets
  • From: "Paul J. Lucas" <email@hidden>
  • Date: Fri, 21 Oct 2005 17:22:33 -0700 (PDT)

If I've got a one-window-only application, then a sheet (ordinarily a
window-modal "dialog") becomes an application modal dialog.

That being the case, it would be nice to have the caller block until
the sheet is dismissed. If I derive aclass from NSAlert, say,
ModalAlertSheet, and add the methods:

	- (int) showAttachedToWindow:
	    (NSWindow*)window
	{
	    [self
	        beginSheetModalForWindow:window
	        modalDelegate:self
	        didEndSelector:@selector(alertEnded:returnCode:contextInfo:)
	        contextInfo:nil
	    ];
	    return [NSApp runModalForWindow:[self window]];
	}

	- (void) alertEnded:
	    (NSAlert*)alert
	    returnCode:(int)returnCode
	    contextInfo:(void*)contextInfo
	{
	    [[alert window] orderOut:self];
	    [NSApp stopModalWithCode:returnCode];
	}

and call it like:

	ModalAlertSheet *alert = [[ModalAlertSheet] alloc] init];
	// ...
	int button = [alert showAttachedToWindow:mainWindow]

then: is this an OK thing to do?  It seems to work just fine.

- Paul
 _______________________________________________
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

  • Prev by Date: Cocoa UI in carbon plug-in?
  • Next by Date: Re: Binding to CoreImage?
  • Previous by thread: Re: Cocoa UI in carbon plug-in?
  • Next by thread: NSView and layers?
  • Index(es):
    • Date
    • Thread