FROM : Lee Ann Rucker
DATE : Tue Jun 26 00:40:57 2007
Funny you should ask; I was just working on the exact same problem,
and having the same results.
Hit google and found that in http://developer.apple.com/documentation/
Cocoa/Conceptual/CocoaBindings/Concepts/MessageFlow.html
12. If the view has an NSFormatter attached to it, the value is
formatted by the NSFormatter instance. Proceed to Step 17.
13. If the controller-model binding specifies a value transformer the
entire model is transformed using the transformedValue: method.
14.The controller generates a key-value observing message, mapping
the key path to the selection. This generates the same type of key-
value observing change notification that would result in replacing
the content object. Proceed to Step 7.
15.If the binding specifies a placeholder for the view-controller
binding for the value marker it is used in Step 16. If no custom
placeholder value is specified as part of the binding, and a custom
default placeholder has been set for the view class and this
particular binding, it is used in Step 16. Otherwise, flow returns to
Step 11.
.An application can assign a custom default placeholder for a class
and binding combination using the NSPlaceholders class method
setDefaultPlaceholder:forMarker:withBinding:.
16.The placeholder value is set for the view using the
setPlaceholderString: or setPlaceholderAttributedString: method.
17. The updated value is displayed in the user interface.
So it looks like it's intentionally skipping the steps we want. This
is very annoying. I tried NSValueTransformer, but adding that to an
editable NSTextField makes it non-editable.
On Jun 21, 2007, at 3:25 AM, Joe Wildish wrote:
> All,
>
> I have a custom subclass of NSFormatter attached to an NSTextField
> (done programmatically). The text field is bound and configured to
> "Continuously Update Values". The behaviour I am getting is that
> the first time a change is made to the field, the setter method
> gets called as you would expect. However, all subsequent changes to
> the field do not trigger the setter method - the next time it is
> called is when focus is moved away from the control.
>
> My formatter isn't doing too much, but I stripped it down to the
> bare minimum anyway:
>
> - (NSString *)stringForObjectValue:(id)obj {
> return [NSString stringWithString:obj];
> }
>
> - (BOOL)getObjectValue:(id *)obj forString:(NSString *)string
> errorDescription:(NSString **)error {
> * obj = [NSString stringWithString:string];
> return YES;
> }
>
> Even with this formatter, the behaviour is still as described. If I
> *don't* attach the formatter, the binding works as you would
> expect. I would be grateful if someone might be able to point out
> what I'm doing wrong.
>
> Cheers,
> -Joe
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
DATE : Tue Jun 26 00:40:57 2007
Funny you should ask; I was just working on the exact same problem,
and having the same results.
Hit google and found that in http://developer.apple.com/documentation/
Cocoa/Conceptual/CocoaBindings/Concepts/MessageFlow.html
12. If the view has an NSFormatter attached to it, the value is
formatted by the NSFormatter instance. Proceed to Step 17.
13. If the controller-model binding specifies a value transformer the
entire model is transformed using the transformedValue: method.
14.The controller generates a key-value observing message, mapping
the key path to the selection. This generates the same type of key-
value observing change notification that would result in replacing
the content object. Proceed to Step 7.
15.If the binding specifies a placeholder for the view-controller
binding for the value marker it is used in Step 16. If no custom
placeholder value is specified as part of the binding, and a custom
default placeholder has been set for the view class and this
particular binding, it is used in Step 16. Otherwise, flow returns to
Step 11.
.An application can assign a custom default placeholder for a class
and binding combination using the NSPlaceholders class method
setDefaultPlaceholder:forMarker:withBinding:.
16.The placeholder value is set for the view using the
setPlaceholderString: or setPlaceholderAttributedString: method.
17. The updated value is displayed in the user interface.
So it looks like it's intentionally skipping the steps we want. This
is very annoying. I tried NSValueTransformer, but adding that to an
editable NSTextField makes it non-editable.
On Jun 21, 2007, at 3:25 AM, Joe Wildish wrote:
> All,
>
> I have a custom subclass of NSFormatter attached to an NSTextField
> (done programmatically). The text field is bound and configured to
> "Continuously Update Values". The behaviour I am getting is that
> the first time a change is made to the field, the setter method
> gets called as you would expect. However, all subsequent changes to
> the field do not trigger the setter method - the next time it is
> called is when focus is moved away from the control.
>
> My formatter isn't doing too much, but I stripped it down to the
> bare minimum anyway:
>
> - (NSString *)stringForObjectValue:(id)obj {
> return [NSString stringWithString:obj];
> }
>
> - (BOOL)getObjectValue:(id *)obj forString:(NSString *)string
> errorDescription:(NSString **)error {
> * obj = [NSString stringWithString:string];
> return YES;
> }
>
> Even with this formatter, the behaviour is still as described. If I
> *don't* attach the formatter, the binding works as you would
> expect. I would be grateful if someone might be able to point out
> what I'm doing wrong.
>
> Cheers,
> -Joe
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Joe Wildish | Jun 21, 12:25 | |
| Lee Ann Rucker | Jun 26, 00:40 | |
| Joe Wildish | Jun 28, 03:02 |






Cocoa mail archive

