the Reverend
the Reverend

Reputation: 12579

Check if NSTextView has been edited

Is there a way to get notified when a NSTextView gets modified?. In a NSTextField I just set the target for the default sent action and works perfectly, but I don't see any sent actions on a NSTextView.

Upvotes: 1

Views: 1585

Answers (2)

Francis McGrew
Francis McGrew

Reputation: 7272

NSTextView inherits from NSText, which conforms to the NSTextDelegate protocol. Look it up in the docs. The method you are looking for is: - (void)textDidChange:(NSNotification *)aNotification which you can either implement in your TextView's delegate or get by registering for a "NSTextDidChangeNotification" notification.

Upvotes: 8

The Lazy Coder
The Lazy Coder

Reputation: 11838

Subclass NSTextField and override the textDidChange method that it has.

The delegate will tell you when it will start editing and when it will finish editing. But the control itself gets the textDidChange method called on itself.

Subclass it and override the method

- (void)textDidChange:(NSNotification *)notification;

then you could set a flag that you can access externally.

Upvotes: 1

Related Questions