如何在 C++ 中显示模式消息框在 Mac 上?
CFUserNotificationDisplayAlert 和 CFUserNotificationDisplayNotice 创建一个非模态窗口 这很糟糕,因为如果您选择原始应用程序窗口(消息框隐藏但应用程序不响应),它可能会使您的应用程序 UI 处于非常不希望的状态。
旧的 SystemAlert 是模态的,但这个不完全支持 Unicode 字符串。
如何在 Mac 下将消息框显示为模态窗口?我正在寻找类似于 Windows 中的 MessageBox 的东西?
CFUserNotificationDisplayAlert and CFUserNotificationDisplayNotice creates a non-modal window and this is bad because it could bring your application UI in a very undesired state if you select the original application window (the message box is hidden but the applicaton does not respond).
The old SystemAlert
was modal but this one doesn't fully support Unicode strings.
How can i display a message box as a modal window under Mac? I'm looking for someting similar to MessageBox from Windows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经使用 CFUserNotificationDisplayAlert 实现了它,并且直到用户关闭 MessageBox 后它才会返回。
如果您想查看代码,我在 Mac 中的 MessageBox 函数
在那里你会发现一个为 mac 实现的 MessageBox 函数,它只为 MB_OKCANCEL 实现,但只需更多代码就可以覆盖整个 MessageBox 标志和返回值,这是一个很好的起点。
I've implemented it with
CFUserNotificationDisplayAlert
and it doesn't return until the user closes the MessageBox.If you want to take a look of the code, I have it in MessageBox function in Mac
there you will find a MessageBox function implemented for mac, it's only implemented for MB_OKCANCEL, but with little more code could cover the entire MessageBox flags and return values, is a good starting point.
看起来
CreateStandardAlert
是正确的解决方案,因为这是模式。It looks that
CreateStandardAlert
is the right solution because this one is modal.看看
NSBeginAlertSheet
函数或 NSApp 的:可能就是你想要的。 这里也是一篇不错的文章关于使用床单。
Have a look at
NSBeginAlertSheet
function or at NSApp's:may be its what you want. Here is also a nice article about working with sheets.