Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTextView value changed

I'm pretty new to mac development (coming from a web and iOS background) and I can't work out how I could get a notification every time the value of an NSTextView changes. Any ideas?

like image 216
tarnfeld Avatar asked Mar 05 '11 08:03

tarnfeld


1 Answers

Ups I just saw that you want a callback from NSTextView and not NSTextField

Just add in the header of the object which should be the delegate the protocol

@interface delegateAppDelegate : NSObject <NSApplicationDelegate, NSTextViewDelegate> {
    NSWindow *window;
}

After that you add a method like

-(void)textDidChange:(NSNotification *)notification {
    NSLog(@"Ok");
}

Make sure you connected the delegate property of the NSTextView (not NSScrollView) with the object which should receive the delegate

like image 155
lbrndnr Avatar answered Sep 20 '22 12:09

lbrndnr