- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我已经在我的应用程序中创建了具有这些设置的主窗口:
[self setLevel:kCGDesktopWindowLevel + 1];
[self setCollectionBehavior:
(NSWindowCollectionBehaviorCanJoinAllSpaces |
NSWindowCollectionBehaviorStationary |
NSWindowCollectionBehaviorIgnoresCycle)];
这是一个非常自定义的窗口,有点漂浮在桌面上方。
此外,它还是一个菜单栏应用程序 (LSUIElement
)。
好的,所以我需要在出现问题时显示警报。这是我的做法:
NSAlert *alert = [NSAlert alertWithMessageText:@""
defaultButton:@""
alternateButton:@""
otherButton:@""
informativeTextWithFormat:@""];
[alert runModal];
当然我已经填写了按钮和其他文本。
这是我的问题:当我的应用程序当前不是关键应用程序时,弹出此警报,它不是关键窗口。像这样:
查看未选中窗口的原因?有没有办法在不改变我的整个应用程序窗口级别的情况下解决这个问题?谢谢!
最佳答案
您是否尝试过在显示警报的代码中激活您的应用程序?
[[NSRunningApplication currentApplication] activateWithOptions:0];
如果传递 0 不起作用,您可以将 NSApplicationActivateIgnoringOtherApps
作为您的选项传递,但 Apple 建议不要这样做,除非确实有必要(请参阅 NSRunningApplication 的文档)。
更新:您在运行警报之前已激活。这适用于设置了 LSUIElement 的新应用程序:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
NSAlert *alert = [NSAlert alertWithMessageText: @"Blah"
defaultButton: @"Blah"
alternateButton: @"Blah"
otherButton: @"Blah"
informativeTextWithFormat: @"Blah"];
[[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
[alert runModal];
}
关于objective-c - 让 NSAlert 成为最顶层的窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5269116/
我需要根据另一个 NSAlert 的响应来调出一个 NSAlert。但是,当我尝试从第一个的 didEndSelector 调用它时,会发生各种令人讨厌的事情(例如我的文档窗口消失以及有关打印到控制台
我需要在应用程序的第 3 次、第 10 次和第 20 次启动时显示 NSAlert,到目前为止我已尝试过: /* Note that the kLaunchCount is incremented a
Apple 最初的 HIG(遗憾的是,现已从网站上消失)指出: 对话框中最右边的按钮(操作按钮)是确认警报消息文本的按钮。操作按钮通常(但并非总是)是默认按钮 就我而言,我有一些破坏性操作(例如删除磁
我正在创建一个全屏应用程序,并且想知道是否有某种方法可以使 NSAlert 位于我创建的 CGDisplayCapture 之上。现在,NSAlert 显示在显示捕获后面。我的主窗口显示得很好(在使用
我有一个带有附件 View 和三个按钮的 NSAlert,这些按钮没有向右对齐(对于 LTR 系统),但似乎扩展到附件 View 的宽度,如下所示 同时删除附件 View ,三个按钮未正确对齐在右侧
我正在创建 Mac OS X 应用程序,并且在 NSAlert 上格式化字符串时遇到一些问题。我希望信息文本的格式如下: 某事某事某事 --------中间加粗--------- 其他事情其他事情其他
如果您在应用程序处于后台时发出 NSAlert,您的 Dock 图标就会开始弹跳,并持续弹跳,直到您切换回来。 我觉得这很烦人。 有谁知道如何为单个应用程序禁用它? 最佳答案 创建您自己的 NSApp
如何打印下面的数组以显示完整的字符串? alert.informativeText = CommandLine.arguments[4] 如果是一个单词,则打印效果很好。参数测试 Test 但是,如果
我正在尝试创建一个带有 2 个按钮的 NSAlert。 let a = NSAlert() a.messageText = "Do you want go to A or B?"
我想用beginSheetModalForWindow创建一个NSAlert,在NSWarningAlertStyle、NSInformationalAlertStyle之间的alertstyle中没
我有一个带有两个按钮的 NSAlert: var al = NSAlert() al.informativeText = "You earned \(finalScore) points" al.me
我发现一个有趣的事情:当我使用“浏览”按钮选择一个文件时,如果该文件已经存在,NSAlert会导致自动更改面板,但我想自己做这个,如何禁用NSAlert的自动更改面板?非常感谢! 最佳答案 您需要实现
我正在使用 NSAlert 要求用户启用辅助设备的辅助功能。是否有可能有一个不关闭 NSAlert 的按钮,我可以用它来打开 UniversalAccess prefpane ? 如果没有,我想我必须
我正在编写一个带有首选项面板的超酷应用程序。如果用户打开首选项面板,更改其首选项,然后关闭面板而不保存这些更改,她将收到 NSAlert,通知她可怕的后果。 NSAlert 工作表有两个按钮:“确定”
如何在 NSAlert 中添加斜体文本的某些部分? NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Warnin
有没有办法在 NSAlert 中插入自定义图标?我知道您可以有不同的 prefabbealert 样式,但是可以 cu 最佳答案 是的。您可以使用 - (void)setIcon:(NSImage *
在 Xcode 5.0.2 中设置要显示为模式表的 NSAlert 对象时,我遇到了一个有趣的惊喜。 我计划使用 beginSheetModalForWindow:modalDelegate:didE
我有一个从 NSStatusItem 显示的 NSPopover。这个 Popover 会时不时地显示 NSAlerts。问题是这些警报总是出现在弹出窗口下方,即使它们成为关键窗口。即使我拖动它,它仍
当我显示这样的 NSAlert 时,我立即得到响应: int response; NSAlert *alert = [NSAlert alertWithMessageText:... ...]; re
NSAlert 的默认外观似乎不太理想。例如,当我单击复选框时,该复选框会消失,并且聚焦的按钮具有白色文本。 [编辑]我应该提到这是一个 Metal 应用程序。 以下是创建 NSAlert 的代码(使
我是一名优秀的程序员,十分优秀!