Ondrej Rafaj
Ondrej Rafaj

Reputation: 4417

How do I detect enter key hit on NSTextField

In a text field, I need to detect user hit Enter (return) key. The delegate methods are completely different from the ones in UITextField so not really sure what to do ... I use swift 2.3 atm.

Upvotes: 1

Views: 1420

Answers (1)

vadian
vadian

Reputation: 285059

When the user hits the enter key the delegate method

func controlTextDidEndEditing(_ aNotification : Notification)

is called.

This is the Swift 3 syntax. Type cont and use code completion to get the Swift 2 syntax.

Upvotes: 8

Related Questions