Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSAlertMBS class.

NSAlertMBS.addButtonWithTitle(title as string) as Variant

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Customize the buttons in the alert panel.
Example
// make dialog
Var a as NSAlertMBS = NSAlertMBS.alertWithMessageText("Hello World", "First Button", "Second Button")

// add button
Var thirdButton as NSButtonMBS = a.addButtonWithTitle("Third Button")

// and show dialog
call a.runModal

Buttons are added from right to left (for left to right languages).
Returns NSButtonMBS object.

Some examples using this method:

NSAlertMBS.beginSheetModalForWindow(win as DesktopWindow)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 22.0 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Begins a sheet on the document window.

If the alert has an alertStyle of NSCriticalAlertStyle, it will be shown as a "critical" sheet; it will otherwise be presented as a normal sheet.
Calls later SheetDidEnd event with the result.

Please keep a reference to the dialog object alive to avoid trouble.
e.g. store reference in parent window, global property or app property.

See also:

NSAlertMBS.beginSheetModalForWindow(win as NSWindowMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Begins a sheet on the document window.

If the alert has an alertStyle of NSCriticalAlertStyle, it will be shown as a "critical" sheet; it will otherwise be presented as a normal sheet.
Calls later SheetDidEnd event with the result.

Please keep a reference to the dialog object alive to avoid trouble.
e.g. store reference in parent window, global property or app property.

See also:

NSAlertMBS.beginSheetModalForWindow(win as window)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Begins a sheet on the document window.

If the alert has an alertStyle of NSCriticalAlertStyle, it will be shown as a "critical" sheet; it will otherwise be presented as a normal sheet.
Calls later SheetDidEnd event with the result.

Please keep a reference to the dialog object alive to avoid trouble.
e.g. store reference in parent window, global property or app property.

See also:

NSAlertMBS.buttons as Variant()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Get the buttons, where the rightmost button is at index 0.
Example
Var a as NSAlertMBS = NSAlertMBS.alertWithMessageText("Hello World", "First Button", "Second Button")
Var buttons() as Variant = a.buttons

for each b as NSButtonMBS in buttons
MsgBox b.title
next

Returns NSButtonMBS array.

NSAlertMBS.close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Closes the alert sheet.

The SheetDidEnd event will not run.

NSAlertMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The constructor for an empty alert.

Use properties to configure the dialog.

NSAlertMBS.Destructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The destructor.

NSAlertMBS.layout

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Performs the layout for the dialog.

Can be used to indicate that the alert panel should do immediate layout, overriding the default behavior of laying out lazily just before showing panel. You should only call this method if you want to do your own custom layout after it returns. You should call this method only after you have finished with NSAlert customization, including setting message and informative text, and adding buttons and an accessory view if needed. You can make layout changes after this method returns, in particular to adjust the frame of an accessory view. Note that the standard layout of the alert may change in the future, so layout customization should be done with caution.

NSAlertMBS.runModal as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 14.2 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Run the alert as an application-modal panel and return the result.
Example
Var a As New NSAlertMBS

a.messageText = "Should be do it?"

// OK button is added by default
Var e As Integer = a.runModal

NSAlertMBS.SetTextAlignment(value as Integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Cocoa MBS MacCocoa Plugin 22.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Changes text alignment for dialog to left text alignment.

on macOS Big Sur and later, the default alignment is center.
If you show multiple lines of text, it may be easier to read with left alignment.

This calls layout method to layout the dialog.

See NSParagraphStyleMBS or NSTextMBS class for the alignment constants.

The items on this page are in the following plugins: MBS MacCocoa Plugin.


The biggest plugin in space...