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

To change the key equivalents for the NSButton elements inside of the NSAlert object, you'll have to access the buttons directly (after creation and before -runModal) and change the key equivalents using the -setKeyEquivalent: method.

For example, to set the Disconnect to be ESC and the Cancel to be return, you would do the following:

NSArray *buttons = [alert buttons];
// note: rightmost button is index 0
[[buttons objectAtIndex:1] setKeyEquivalent: @"\033"];
[[buttons objectAtIndex:0] setKeyEquivalent:@"\r"];

before calling -runModal