Function

NSRunAlertPanel

Creates an alert panel.

Declaration

NSInteger NSRunAlertPanel(NSString *title, NSString *msgFormat, NSString *defaultButton, NSString *alternateButton, NSString *otherButton, ...);

Discussion

Creates and runs an alert panel (or dialog) with the title of title and buttons with titles of defaultButton, alternateButton, and otherButton. The optional alert message specified by msgFormat should be a static value that can consist of variable values using a format string (list any necessary arguments for this formatted string at the end of the function’s argument list), an unformatted string, or an empty string (@""), but not nil. Note that passing an untrusted string in msgFormat can lead to security issues. See the description of NSBeginAlertSheet for information on layout of buttons, default parameters, and possible return values. NSRunAlertPanel runs the panel in a modal event loop.

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.

This function not only creates the panel; it also puts the panel onscreen and runs it using the runModalForWindow: method defined in the NSApplication class. This method sets up a modal event loop that causes the panel to remain onscreen until the user clicks one of its buttons. This function then removes the panel from the screen list and returns a value that indicates which of the three buttons the user clicked. For efficiency, this function creates the panel the first time it’s called and reuses it on subsequent calls, reconfiguring it if necessary.

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.

NSBeginAlertSheet

Creates and runs an alert sheet.

Deprecated
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
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