Xcode set default button on enter when making a form

后端 未结 2 1171
独厮守ぢ
独厮守ぢ 2021-02-15 11:03

I\'m making a form in Xcode using objective-c and cocoa. In the interface builder I have 2 textfields and 2 buttons. When I build the project and run it, neither of the two butt

相关标签:
2条回答
  • 2021-02-15 11:20

    A link to Apple's documentation is here: http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/Button/Articles/MakingaButtontheDefaultButton.html

    this code sets the return key to be the default:

    [myButton setKeyEquivalent:@"\r"];
    

    not mentioned in the docs, but to programmatically remove that key, you would use:

    [myButton setKeyEquivalent:@""];
    
    0 讨论(0)
  • 2021-02-15 11:24

    You set the Key Equivalent value for your button in IB. Just click on that field in the attributes inspector and press the enter key.

    0 讨论(0)
提交回复
热议问题