nsalert

Tips on NSApp’s ModalForWindow, NSAlert’s ModalForWindow, and ModalSession [closed]

荒凉一梦 提交于 2019-12-02 17:07:31
It took me quite a bit of experimentation to clear up some confusion over Objective-C’s “ModalForWindow” language and, subsequently, how to use a modal session. Maybe the following tips will save somebody some time: (In case you’re new to the concept: When a window, usually a panel, runs modal, it prevents some other part of the app from responding until it has been dismissed.) “ModalForWindow” means different things in different circumstances. If you are using loadNibNamed to display a panel defined by a xib and you want it to run modal, call this once it is displayed: // Make

Creating a fully customized NSAlert

泪湿孤枕 提交于 2019-11-28 12:22:14
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 runModal] ). I just want to change the background, really, and the text color, of course. Warning about the recommended solution: This code causes wasteful and pointless overhead: for (;;) { if ([NSApp runModalSession:session] != NSRunContinuesResponse) break; } This code is copied straight from the Apple documentation page - but it's meant to show the developer where meaningful code can be inserted for background execution while

Create an NSAlert with Swift

戏子无情 提交于 2019-11-27 17:42:21
I have the code to create and NSAlert in Objective-C but I would now like to create it in Swift. The alert is to confirm that the user would like to delete a document. I would like the "delete" button to then run the delete function and the "cancel" one just to dismiss the alert. How can I write this in Swift? NSAlert *alert = [[[NSAlert alloc] init] autorelease]; [alert addButtonWithTitle:@"Delete"]; [alert addButtonWithTitle:@"Cancel"]; [alert setMessageText:@"Delete the document?"]; [alert setInformativeText:@"Are you sure you would like to delete the document?"]; [alert setAlertStyle

Create an NSAlert with Swift

余生长醉 提交于 2019-11-27 04:13:22
问题 I have the code to create and NSAlert in Objective-C but I would now like to create it in Swift. The alert is to confirm that the user would like to delete a document. I would like the "delete" button to then run the delete function and the "cancel" one just to dismiss the alert. How can I write this in Swift? NSAlert *alert = [[[NSAlert alloc] init] autorelease]; [alert addButtonWithTitle:@"Delete"]; [alert addButtonWithTitle:@"Cancel"]; [alert setMessageText:@"Delete the document?"]; [alert