Creating a fully customized NSAlert

后端 未结 3 1715
误落风尘
误落风尘 2020-12-11 04:47

Is it possible to create a fully customized alert? I\'m doing it with custom sheets now, but I\'d like to have the feature that the sheet is blocking (like -[NSAlert r

3条回答
  •  借酒劲吻你
    2020-12-11 05:38

    I looked around a bit, and found this piece of code :

    NSModalSession session = [NSApp beginModalSessionForWindow:sheetWindow];
    for (;;) {
        if ([NSApp runModalSession:session] != NSRunContinuesResponse)
            break;
    }
    [NSApp endModalSession:session];
    

    I call

    [NSApp stopModal]
    

    to end the session. Now my code is way cleaner :)

提交回复
热议问题