B
B
big_jump2014-02-23 15:28:19
Objective-C
big_jump, 2014-02-23 15:28:19

Xcode TextField: How to make a method call on pressing the Enter key on the keyboard?

There is NSTextField and Button, they are connected by method. When the Button is clicked, a method is called that takes information from the NSTextField. How can I make the same method be called on pressing the Enter key on the keyboard, after entering text into the NSTextField?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
big_jump, 2014-02-23
@big_jump

Already figured it out myself. For NSTextField, we add an Action, in which we describe the method call described for a regular Push Button. In my case it looks like this

- (IBAction)enterButton:(id)sender {
    [self  pushButton:sender];
}

In IB, in the NSTextField settings, Attributes Inspector, set the Action parameter to Send On Enter Only.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question