Charlie Egan
Charlie Egan

Reputation: 5153

NSTextField call IBAction on text change

In visual studio there is an event called text_changed for text boxes, how can I create a similar event/Action in Cocoa?

And in general how do you get these extra events for form controls? e.g. mouse over, in visual studio you just choose from a list of events.

Upvotes: 4

Views: 3157

Answers (1)

puzzle
puzzle

Reputation: 6131

You want to set yourself (i.e. the app delegate, or whatever controller you've got for managing that view) as the delegate of your NSTextField. Then implement the method

- (void)controlTextDidChange:(NSNotification *)aNotification

It gets called whenever the text in the text field changes.

For an introduction to handling mouse events, such as mouse over, the Cocoa Event Handling Guide is a pretty good starting point.

Upvotes: 5

Related Questions