NSAlert
クラスを使用してアプリケーションモーダルアラートを表示するCocoaアプリケーションがあります。私は警告ウィンドウを他のすべてのアプリケーションのウィンドウの上に浮かべたいと思います。 NSAlert
でこれを行うことはできますか?それとも自分のウィンドウを実装する必要がありますか?NSAlertを使用してフローティングウィンドウを作成できますか?
この問題があるかどうかわかりませんが、アプリケーションはNSStatusItem
として実装されているエージェントアプリケーション(LSUIElement
が該当)です。 (<here>を見て、ソースコードを含むアプリケーションについての詳細情報については、。)
ここで警告を表示するコードは次のとおりです。
- (void)showTimerExpiredAlert {
[NSApp activateIgnoringOtherApps:YES];
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSInformationalAlertStyle];
[alert setMessageText:NSLocalizedString(@"Menubar Countdown Complete", @"Expiration message")];
[alert setInformativeText:NSLocalizedString(@"The countdown timer has reached 00:00:00.",
@"Expiration information")];
[alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button title")];
[alert addButtonWithTitle:NSLocalizedString(@"Restart Countdown...", @"Restart button title")];
NSInteger clickedButton = [alert runModal];
[alert release];
if (clickedButton == NSAlertSecondButtonReturn) {
// ...
}
}
私はrunModal
呼び出し前にこれを入れて試してみた:
[[alert window] setFloatingPanel:YES];
私はこれも試してみた:
[[alert window] setLevel:NSFloatingWindowLevel];
しかしneitを他のアプリケーションのウィンドウをクリックすると、そのウィンドウが他のウィンドウの上に残ります。私はrunModal
これらの設定のいずれかを尊重しないと思う。
runModalが呼び出されるたびにウィンドウレベルがリセットされます。 – cobbal