2

I would like to use a NSAlert in my OSX application to deal with user authentication.

The answer to this question pop up style dialog covers the basics but I can't figure out how to expand a accessoryView to include two inputs and a label for each.

This produces a single text input:

NSAlert *myAlertView = [[NSAlert alloc]init];

NSTextField *input = [[NSTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 24)];
[input setStringValue:@""];
[myAlert setAccessoryView:input];

Any suggestions would be greatly appreciated.

Community
  • 1
  • 1
ThunderHorse
  • 365
  • 1
  • 4
  • 18

1 Answers1

7

At the point where you start needing to add inputs, what you are creating is no longer an alert dialog. Create a NSPanel in the Interface Builder with the necessary controls and use that instead.

  • Thanks for the suggestion, looking into the NSPanel solution now. Seems to be exactly what I need. – ThunderHorse Jan 18 '13 at 02:01
  • 2
    Sorry, but NSPanels (at least as they come in IB) lack lot's of "NSAlert"ness. The standard text size and alignment, the severity icon, much more. Also, when used as a sheet - NSPanels loose their title, so you actually have to set up everything within the NSPanel's content view – Motti Shneor Jun 21 '14 at 23:43