MonoMac 中是否有等价物MessageBox.Show()
,还是我必须专门为此目的创建某种弹出类?
问问题
1965 次
1 回答
9
您正在寻找 NSAlert,它几乎等同于 MessageBox。
您可以使用 NSAlert.RunModal() 来显示 NSAlert,如果您希望它在特定窗口上显示为工作表,则可以使用 NSAlert.BeginSheet()。
例如
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
你可以在这里从 MonoMac 的角度来看看如何更多地使用它:
https://github.com/picoe/Eto/blob/master/Source/Eto.Platform.Mac/Forms/MessageBoxHandler.cs
于 2012-05-10T16:46:00.887 回答