我有带有自定义 NSView 的 NSWindow。这个自定义的 NSView 覆盖 performDragOperation 方法。拖放操作效果很好。但是当我创建 NSAlert 并将其显示为模式窗口时,我需要块拖放,不应该调用方法 performDragOperation。
NSAlert *alert = [[NSAlert alloc]init];
[alert addButtonWithTitle:@"Excellent"];
[alert setMessageText:@"This is your message."];
[alert runModal];
一种可能的解决方案是添加代码来验证对话框是否显示为 performDragOperation 方法。但是如何检测是否显示了 NSAlert。例如,对于我可以使用的工作表:
if([window attachedSheet]) {
...
}
但是如何做到这一点
[alert runModal];