Function

NSBeginAlertSheet

Creates and runs an alert sheet.

Declaration

void NSBeginAlertSheet(NSString *title, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, NSWindow *docWindow, id modalDelegate, SEL didEndSelector, SEL didDismissSelector, void *contextInfo, NSString *msgFormat, ...);

Discussion

Creates and runs an alert sheet on docWindow, with the title of title, the text of msg, and buttons with titles of defaultButton, alternateButton, and otherButton.

The buttons are laid out on the lower-right corner of the sheet, with defaultButton on the right, alternateButton on the left, and otherButton in the middle. If title is nil or an empty string, a default localized title is used (“Alert” in English). If defaultButton is nil or an empty string, a default localized button title (“OK” in English) is used. For the remaining buttons, this function creates them only if their corresponding button title is non-nil.

A Command-D key equivalent for the “Don’t Save” button is provided, if one is found. The button titles are searched for the localized value for “Don’t Save.” If a match is found, that button is assigned a Command-D key equivalent, provided it is not the default button.

If you create a modal panel using runModalForWindow: or beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:, you can assign the key equivalent yourself, using keyEquivalent and keyEquivalentModifierMask.

The msg argument is the message that’s displayed in the panel. It can use printf-style formatting characters; any necessary arguments should be listed at the end of the function’s argument list (after the msg argument). For more information on formatting characters, see the man page for printf.

When the modal session is ended, and before the sheet is dismissed, the didEndSelector is invoked on the modalDelegate. passing contextInfo. After the sheet is dismissed, the didDismissSelector is invoked on the modalDelegate, passing contextInfo. Typically, you will want to implement the didEndSelector but you may pass NULL for the didDismissSelector. The two selectors should be defined as follows:

sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void  *)contextInfo;
sheetDidDismiss:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void  *)contextInfo;

where sheet is the alert sheet, returnCode specifies which button the user pressed, and contextInfo is the same contextInfo passed into NSBeginAlertSheet. returnCode can be one of the following:

See Also

Views and Controls

NSForm

An NSForm object is a vertical matrix of NSFormCell objects to implement the fields.

Deprecated
NSFormCell

The NSFormCell class is used to implement text entry fields in a form. The left part of an NSFormCell object contains a title. The right part contains an editable text entry field.

NSMenuItemCell

An object that handles the measurement and display of a single menu item in its encompassing frame.

NSBeginCriticalAlertSheet

Creates and runs a critical alert sheet.

Deprecated
NSBeginInformationalAlertSheet

Creates and runs an informational alert sheet.

Deprecated
NSGetAlertPanel

Returns an alert panel.

Deprecated
NSGetCriticalAlertPanel

Returns an alert panel to display a critical message.

Deprecated
NSGetInformationalAlertPanel

Returns an alert panel to display an informational message.

Deprecated
NSReleaseAlertPanel

Disposes of an alert panel.

Deprecated
NSRunAlertPanel

Creates an alert panel.

Deprecated
NSRunCriticalAlertPanel

Creates and runs a critical alert panel.

Deprecated
NSRunInformationalAlertPanel

Creates and runs an informational alert panel.

Deprecated
NSInputManagerDeprecated
NSInputServerDeprecated
NSDisableScreenUpdates

Disables screen updates.

Deprecated
NSEnableScreenUpdates

Enables screen updates.

Deprecated