diff --git a/AppKit/CPCheckBox.j b/AppKit/CPCheckBox.j index d58c49402..c13c3b5cc 100644 --- a/AppKit/CPCheckBox.j +++ b/AppKit/CPCheckBox.j @@ -110,40 +110,15 @@ CPCheckBoxImageOffset = 4.0; [self _setPlaceholder:CPOffState forMarker:CPNullMarker isDefault:YES]; } -- (void)setValueFor:(CPString)theBinding +- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding { - var destination = [_info objectForKey:CPObservedObjectKey], - keyPath = [_info objectForKey:CPObservedKeyPathKey], - options = [_info objectForKey:CPOptionsKey], - newValue = [destination valueForKeyPath:keyPath], - isPlaceholder = CPIsControllerMarker(newValue); + [_source setAllowsMixedState:(aValue === CPMixedState)]; + [_source setState:aValue]; +} - if (isPlaceholder) - { - if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption]) - { - [CPException raise:CPGenericException - reason:@"can't transform non applicable key on: " + _source + " value: " + newValue]; - } - - newValue = [self _placeholderForMarker:newValue]; - - if (newValue === CPMixedState) - { - [_source setAllowsMixedState:YES]; - } - else - { - // Cocoa will always set allowsMixedState to NO - // This behavior will be fine for Cappuccino as well if we (like Cocoa) - // default the CPConditionallySetsEnabledBindingOption to YES - [_source setAllowsMixedState:NO]; - } - } - else - newValue = [self transformValue:newValue withOptions:options]; - - [_source setState:newValue]; +- (void)setValue:(id)aValue forBinding:(CPString)aBinding +{ + [_source setState:aValue]; } @end diff --git a/AppKit/CPKeyValueBinding.j b/AppKit/CPKeyValueBinding.j index 89b4214e2..d7518026d 100644 --- a/AppKit/CPKeyValueBinding.j +++ b/AppKit/CPKeyValueBinding.j @@ -149,15 +149,40 @@ var CPBindingOperationAnd = 0, return self; } -- (void)setValueFor:(CPString)aBinding +- (void)setValueFor:(CPString)theBinding { var destination = [_info objectForKey:CPObservedObjectKey], keyPath = [_info objectForKey:CPObservedKeyPathKey], options = [_info objectForKey:CPOptionsKey], - newValue = [destination valueForKeyPath:keyPath]; + newValue = [destination valueForKeyPath:keyPath], + isPlaceholder = CPIsControllerMarker(newValue); - newValue = [self transformValue:newValue withOptions:options]; - [_source setValue:newValue forKey:aBinding]; + if (isPlaceholder) + { + if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption]) + { + [CPException raise:CPGenericException + reason:@"Can't transform non applicable key on: " + _source + " Key Path:" + keyPath + " value: " + newValue]; + } + + var value = [self _placeholderForMarker:newValue]; + [self setPlaceholderValue:value withMarker:newValue forBinding:theBinding]; + } + else + { + var value = [self transformValue:newValue withOptions:options]; + [self setValue:value forBinding:theBinding]; + } +} + +- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding +{ + [_source setValue:aValue forKey:aBinding]; +} + +- (void)setValue:(id)aValue forBinding:(CPString)aBinding +{ + [_source setValue:aValue forKey:aBinding]; } - (void)reverseSetValueFor:(CPString)aBinding diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 5f3197720..0145649c2 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1521,32 +1521,15 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", [self _setPlaceholder:@"" forMarker:CPNullMarker isDefault:YES]; } -- (void)setValueFor:(CPString)theBinding +- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding { - var destination = [_info objectForKey:CPObservedObjectKey], - keyPath = [_info objectForKey:CPObservedKeyPathKey], - options = [_info objectForKey:CPOptionsKey], - newValue = [destination valueForKeyPath:keyPath], - isPlaceholder = CPIsControllerMarker(newValue); + [_source setPlaceholderString:aValue]; + [_source setObjectValue:nil]; +} - if (isPlaceholder) - { - if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption]) - { - [CPException raise:CPGenericException - reason:@"can't transform non applicable key on: " + _source + " value: " + newValue]; - } - - newValue = [self _placeholderForMarker:newValue]; - - [_source setPlaceholderString:newValue]; - [_source setObjectValue:nil]; - } - else - { - newValue = [self transformValue:newValue withOptions:options]; - [_source setObjectValue:newValue]; - } +- (void)setValue:(id)aValue forBinding:(CPString)aBinding +{ + [_source setObjectValue:aValue]; } @end