On Sep 11, 2012, at 9:41 AM, Koen van der Drift wrote:

> On Tue, Sep 11, 2012 at 11:26 AM, Keary Suska <[email protected]> 
> wrote:
>> On Sep 11, 2012, at 7:17 AM, Koen van der Drift wrote:
>> 
>>> And as a followup, I am using bindings to link the value of the
>>> textfield to my controller to do the calculations. I als tried
>>> checking "Continuously Updates Value" in IB, but that also didn't
>>> work, I still need to unfocus the textfield for the new value to be
>>> used.
>> 
>> "Continuously Updates Value" is what you want, usually. I bet that if you 
>> put NSLogs in the setters you will find that they are being set immediately. 
>> If this isn't working, it means that your calculation method is not working 
>> on the same model as the bindings, or at least not an up-to-date copy, which 
>> is generally a bad idea. The calculation method should retrieve the values 
>> directly from the model owner on demand, which will do what you need.
> 
> 
> Without being able to look at my project since I am not at my Mac, I'm
> pretty sure I set it up correctly. The myViewController class which
> does the calculations has @properties for the values stored in the
> textfields, and in IB the textfields are bound to
> myViewController.value1, etc. The are no setters/getters for these
> values.
> 
> Another thought I had why it doesn't work, is that I connected a
> formatter to the textfield in IB to allow integers only.  Could that
> be related to what I am seeing?

Could be - here's rdar://5293557 which is still open; it modifies the 
NSMutableString in place instead of going through the setter. It also plays 
merry hell with Undo - the validation prevents certain letters from being added 
to the string, but undo thinks they did get added so it tries to remove more 
characters than exist.

25-Jun-2007 04:05 PM Lee Ann Rucker:
If I attach an NSFormatter to an NSTextField that has a binding set to 
continuously update values, the bound value gets updated the first time 
something is typed into the field, but not thereafter. I expected it to be 
updated every time, or not at all.

>From Google and cocoa-dev searches, this seems to be a known problem or even 
>expected behaviour, but it is very annoying as the field in question requires 
>both validation and formatting (a Windows serial number which will fail if in 
>the wrong format). If there's a workaround for this please let me know.

The attached program has a very simple formatter which demonstrates the problem 
- the top text field has a formatter, the bottom and otherwise identical one 
does not.


'FormatterIssues.zip' was successfully uploaded

24-Sep-2007 02:56 PM Lee Ann Rucker:
Further investigation has revealed that the bound value *is* updated, but the 
accessor method only gets called once on the first change to the value. Even 
having accessInstanceVariablesDirectly return NO does not change this. 


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to