Is there MessageBox.Show () equivalent in MonoCode

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

+5
source share
1 answer

You are looking for an NSAlert that is basically equivalent to a MessageBox.

You can show NSAlert with NSAlert.RunModal () or use NSAlert.BeginSheet () if you want it to appear as a sheet in a specific window.

eg.

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 see how to use it a little more from the point of view of MonoMac here:

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

+9
source

All Articles