Questions tagged [nsalert]

126 questions
56
votes
6 answers

Create an NSAlert with Swift

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…
Tom Coomer
  • 6,227
  • 12
  • 45
  • 82
36
votes
1 answer

New auto layout errors with Xcode 8.1

I have a macOS app that was running just fine until I upgraded to Xcode 8.1. The app opens a dialogue with NSOpenPanel to allow the user to choose an image. When I select an image and choose "Open" I get the following error: 2016-11-03…
Peter Wiley
  • 820
  • 7
  • 19
31
votes
1 answer

Tips on NSApp’s ModalForWindow, NSAlert’s ModalForWindow, and ModalSession

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…
Wienke
  • 3,723
  • 27
  • 40
14
votes
2 answers

Focus NSAlert accessory item

I have an NSAlert item that uses an NSTextField as an accessory item to provide an prompt-like dialog box. The only problem that I have is that when the alert is ran the text field is not focused. I tried looking for a way to change NSAlert's first…
JohnM
  • 161
  • 5
14
votes
2 answers

How to make the NSAlert's 2nd button the return button?

I'd like to make something like this NSAlert: As you can see, the 'return' button is the second one. How can I do this? Here's an example of the code that I use to create my NSAlert, but the first button gets the focus: NSAlert *alert = [[NSAlert…
Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76
10
votes
3 answers

Make a NSAlert the topmost window?

I've created the main window in my application to have these settings: [self setLevel:kCGDesktopWindowLevel + 1]; [self setCollectionBehavior: (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorStationary | …
sudo rm -rf
  • 29,408
  • 19
  • 102
  • 161
9
votes
3 answers

NSAlert multiple buttons

I have one NSAlert with two buttons: var al = NSAlert() al.informativeText = "You earned \(finalScore) points" al.messageText = "Game over" al.showsHelp = false al.addButtonWithTitle("New Game") al.runModal() It's working perfectly, but I don't…
user4226616
8
votes
3 answers

Creating a fully customized NSAlert

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…
Fatso
  • 1,278
  • 16
  • 46
8
votes
2 answers

Can NSAlert Be Used to Create a Floating Window?

I have a Cocoa application that displays an application-modal alert using the NSAlert class. I'd like the alert window to float above all other applications' windows. Can this be done with NSAlert, or do I need to implement my own window? I don't…
Kristopher Johnson
  • 81,409
  • 55
  • 245
  • 302
8
votes
2 answers

[__NSCFConstantString pointSize]: unrecognized selector sent to instanc

I am trying to put a Attributed string inside a NSTextField, which itself is inside an NSAlert Here is my code: NSTextField *label1 = [[NSTextField alloc]initWithFrame:NSMakeRect(0, 23, 50, 20)]; [label1 setEditable:FALSE]; [label1…
benjih555
  • 931
  • 2
  • 10
  • 25
7
votes
1 answer

Multiple NSTextField in an NSAlert - MacOS

I am putting together a login dialog using an NSAlert in Swift 4 on MacOS. Here is the code I have so far: func dialogOKCancel(question: String, text: String) -> (String, String) { let alert = NSAlert() alert.messageText = question …
CorlinP
  • 169
  • 1
  • 2
  • 15
7
votes
1 answer

How do I write an NSAlert in latest swift?

I'm trying to write this alert: func alertUser() { let alert = NSAlert() alert.messageText = "message 1" alert.informativeText = "info1" alert.informativeText = "info2" alert.addButton(withTitle: "NO") …
ICL1901
  • 7,632
  • 14
  • 90
  • 138
5
votes
2 answers

NSAlert box is not showing up

I'm working on my first ever cocoa/Objective-C application, so please bear with me if I'm doing something obviously incorrect. I have the application set up to copy down whatever is in an NSTextField on the window to another NSTextField (in this…
airplaneman19
  • 1,139
  • 6
  • 19
  • 32
5
votes
2 answers

macOS Apple Help Authoring - Anchors

I'm trying to make an Apple Help book for my macOS app that I'm ready to release. However, I am trying to make anchors work in my HTML. By Apple's definition: "Anchors allow you to uniquely identify topics in your help book. When a user follows…
Mario A Guzman
  • 3,483
  • 4
  • 27
  • 36
5
votes
2 answers

How to place a question mark button in a NSAlert that opens an online web page?

EDIT: My question was not very clear now I edited it to make it clear that I need to open an online web page and not the help book. I would like to include a question mark button in a NSAlert in a macOS project that points to an online web page with…
Cue
  • 2,952
  • 3
  • 33
  • 54
1
2 3
8 9