NSButton default button with blueish look

后端 未结 5 864
感情败类
感情败类 2021-02-03 23:36

I have a dialog with 1 or more buttons and want to be able to programmatically set the rightmost one be the default one, so that when the user presses the Enter or Return key it

5条回答
  •  粉色の甜心
    2021-02-04 00:12

    I was missing to set the button bezel style properly and that's why it didn't look properly. I'm now setting the button as this:

    [btn setBezelStyle:NSRoundedBezelStyle];
    

    Then any of these work to set the default button:

    [myWindow setDefaultButtonCell:[btn cell]]; 
    

    or

    [btn setKeyEquivalent:@"\r"] 
    

提交回复
热议问题