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


i'd make nsalert:
enter image description here

as can see, 'return' button second one. how can this?
here's example of code use create nsalert, first button gets focus:

nsalert *alert = [[nsalert alloc] init]; [alert setmessagetext:@"are sure want disconnect?"]; [alert addbuttonwithtitle:@"disconnect"]; [alert addbuttonwithtitle:@"cancel"]; [alert runmodal]; 

i want focus "cancel" button. ideas? thanks!

to change key equivalents nsbutton elements inside of nsalert object, you'll have access buttons directly (after creation , before -runmodal) , change key equivalents using -setkeyequivalent: method.

for example, set disconnect esc , cancel return, following:

nsarray *buttons = [alert buttons]; // note: rightmost button index 0 [[buttons objectatindex:1] setkeyequivalent: @"\033"]; [[buttons objectatindex:0] setkeyequivalent:@"\r"]; 

before calling -runmodal


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -