Is there a MessageBox.Show() equivelant in MonoCode

.net, monomac

Solution

You're looking for NSAlert, which is a mostly equivalent to MessageBox.

You can show an NSAlert by using NSAlert.RunModal(), or use NSAlert.BeginSheet() if you want it to show up as a sheet on a particular window.

e.g.

var alert = new NSAlert {
    MessageText = "Hello, this is an alert!",
    AlertStyle = NSAlertStyle.Informational
};

alert.AddButton ("OK");
alert.AddButton ("Cancel");

var returnValue = alert.RunModal();
// returnValue will be 1000 for OK, 1001 for Cancel

You can take a look at how to use it a bit more from a MonoMac perspective here:

https://github.com/picoe/Eto/blob/master/Source/Eto.Platform.Mac/Forms/MessageBoxHandler.cs

Problem

Is there an equivalent of `MessageBox.Show()` in MonoMac, or do I have to create a some sort of popup class specifically for this purpose?

Original source