From b63e50dacb16fe35444cd911c9cbbe12268d1576 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Sun, 20 Sep 2009 19:33:03 -0700 Subject: [PATCH] Fix for the objectValue/value thing in bindings. Removed unnecessary code in CPControl --- AppKit/CPControl.j | 11 ----------- AppKit/CPKeyValueBinding.j | 14 ++++++++++---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index 21ef0bb49..ae0643715 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -149,17 +149,6 @@ var CPControlBlackColor = [CPColor blackColor]; return self; } -- (void)bind:(CPString)binding toObject:(id)anObject withKeyPath:(CPString)keyPath options:(CPDictionary)options -{ - if ([binding isEqual: CPValueBinding]) - { - [self unbind: binding]; - [[CPKeyValueBinding alloc] initWithBinding: @"objectValue" name:CPValueBinding to:anObject keyPath:keyPath options:options from:self]; - } - else - [super bind:binding toObject:anObject withKeyPath:keyPath options:options]; -} - /*! Sets the receiver's target action @param anAction Sets the action message that gets sent to the target. diff --git a/AppKit/CPKeyValueBinding.j b/AppKit/CPKeyValueBinding.j index 5eb722778..b145920ab 100644 --- a/AppKit/CPKeyValueBinding.j +++ b/AppKit/CPKeyValueBinding.j @@ -119,8 +119,6 @@ var CPBindingOperationAnd = 0, if (options) [_info setObject:options forKey:CPOptionsKey]; - //_replacementKeyPathForBinding - [aDestination addObserver:self forKeyPath:aKeyPath options:CPKeyValueObservingOptionNew context:aBinding]; var bindings = [bindingsMap objectForKey:[_source hash]]; @@ -259,7 +257,7 @@ var CPBindingOperationAnd = 0, CPLog.warn("No binding exposed on "+self+" for "+aBinding); [self unbind:aBinding]; - [[CPKeyValueBinding alloc] initWithBinding:aBinding name:aBinding to:anObject keyPath:aKeyPath options:options from:self]; + [[CPKeyValueBinding alloc] initWithBinding:[anObject _replacementKeyPathForBinding:aBinding] name:aBinding to:anObject keyPath:aKeyPath options:options from:self]; } - (CPDictionary)infoForBinding:(CPString)aBinding @@ -272,6 +270,14 @@ var CPBindingOperationAnd = 0, [CPKeyValueBinding unbind:aBinding forObject:self]; } +- (id)_replacementKeyPathForBinding:(CPString)binding +{ + if ([binding isEqual:@"value"]) + return @"objectValue"; + + return binding; +} + @end @implementation _CPKeyValueOrBinding : CPKeyValueBinding @@ -398,7 +404,7 @@ CPHiddenBinding = @"CPHiddenBinding"; CPSelectedIndexBinding = @"CPSelectedIndexBinding"; CPTextColorBinding = @"CPTextColorBinding"; CPToolTipBinding = @"CPToolTipBinding"; -CPValueBinding = @"objectValue"; +CPValueBinding = @"value"; //Binding options constants CPAllowsEditingMultipleValuesSelectionBindingOption = @"CPAllowsEditingMultipleValuesSelectionBindingOption";