On Wed, Aug 20, 2014, at 02:35 PM, Carl Hoefs wrote: > > On Aug 20, 2014, at 12:33 PM, Kyle Sluder <k...@ksluder.com> wrote: > > > On Wed, Aug 20, 2014, at 02:27 PM, Carl Hoefs wrote: > >> I do have -controlTextDidChange: set up, and it does get invoked on every > >> keystroke typed into the textfields, but how do I then cause the > >> textfield’s action method to be issued? > >> -Carl > > > > You don't. You're already getting notified at the right time; just call > > the right method yourself. > > > Which method? I have a KVO setup that does everything already, but it > requires the Action be sent by the textfield. How can I do that from > within -controlTextDidChange:? Otherwise nothing happens until a Return > is pressed.
First, you need to stop using KVO for this. As I said before, NSTextField is not documented to be KVO complaint for any of its properties, so you cannot observe it. To use -controlTextDidChange:, you would have to move your core logic that updates the other text fields out to a common place that can be called by both -controlTextDidChange: and your text field action. Your implementation of -controlTextDidChange: would have to grab the text field's formatter and attempt a string-to-number conversion, calling your core logic method with the results. But rather than doing that, Cocoa Bindings actually does what you want. (And the fact it usually—but not always!—uses KVO under the hood is probably why you've been getting away with KVO-observing your text fields.) Bind your text fields' Value binding to various NSNumber properties on your controller. Turn on Updates Value Continuously for all of these bindings. (I just confirmed that this works, unlike the isContinuous property on NSTextField itself.) Make sure your setters do the proper KVO-compliant updates for the other properties, either through +keyPathsForValuesAffecting… or by manual KVO notification. --Kyle Sluder _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com