Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode set default button on enter when making a form

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 buttons are selected (highlighted in blue as opposed to white). When the user is writing in the text field the ENTER key needs to trigger one of the buttons to be pressed.

How do I do this?

like image 469
Seb123 Avatar asked Aug 07 '12 16:08

Seb123


People also ask

How do I program a button in Swift?

swift in your assistant editor. You can do this by holding Option on your keyboard and clicking the ViewController. swift file in your Project Navigator. Now click on the button, hold CTRL and then drag it to your Swift file.


1 Answers

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.

like image 132
rdelmar Avatar answered Jan 04 '23 11:01

rdelmar