How to create a Binding that updates for every keypress of an NSTextField?

Viewed 203

I wrote a custom NSView in Swift (to display a password strength) and made it KVC and KVO compatible.

I am binding the value of an NSTextField to the value of the custom NSView using:

textField.bind("value", to: strengthView, withKeyPath: "value", options: nil) 

This works fine, except the binded value is only updated when I press enter or if the text field looses focus.

Question: is there an elegant way to make the binding update for every key-press in the NSTextField?

1 Answers

Try with the option for the binding NSContinuouslyUpdatesValueBindingOption. You can get an overview for all the options on the bindings options reference website. The easiest way to test all the options for a control is to use the bindings in Interface Builder.

Related