You need to change the value of the property when the user changes the text in the NSTextField component. NSTextField is created programmatically. The property is declared in the controller as follows:

 @property (nonatomic) NSString* lineName; -(void)setLineName:(NSString*)value { NSLog(@"%s", value); _lineName = value; } 

NSTextField is created in codes, and its stringValue property is bound to the controller property lineName.

 NSTextField* textField = [[NSTextField alloc] init]; ... [self.bind:@"lineName" toObject:textField withKeyPath:@"stringValue" options:@{} ] 

I get the following behavior. If the user enters text into a textField , nothing happens. If textField set to stringValue programmatically (textField.stringValue = @"AAAAAAA") , then the binding is triggered - the setter of the stringValue property is stringValue .

Tell me how to handle the completion of user input in NSTextField, created programmatically?

  • Do you have a custom NSWindow? - Vitali Eller
  • one
    Maybe you need to override the method - (BOOL) canBecomeKeyWindow {} and return YES; And do you have a delegate? - Vitali Eller
  • Delegate for textField not installed - pier_nasos
  • NSTextField is used as is, but is inherited on its component by the NSView inheritor. - pier_nasos
  • See delegates in the documentation for UITextField, do not forget about installing delegate and datasource in the controller for UITextField - pragmus

0