From d686a0dadf678c2eac8fdf4e4bcc12a68531e178 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Wed, 30 Jul 2014 21:09:41 +0200 Subject: [PATCH] reverseSetValuesFor: handle multiple selection --- AppKit/CPTextField.j | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 899c460b9..0b85ef76c 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1957,6 +1957,23 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", [_source setObjectValue:aValue]; } +- (void)reverseSetValueFor:(CPString)aBinding +{ + var destination = [_info objectForKey:CPObservedObjectKey], + keyPath = [_info objectForKey:CPObservedKeyPathKey], + options = [_info objectForKey:CPOptionsKey], + newValue = [self valueForBinding:aBinding], + value = [destination valueForKeyPath:keyPath]; + + if (CPIsControllerMarker(value) && newValue == nil) return; + + newValue = [self reverseTransformValue:newValue withOptions:options]; + + [self suppressSpecificNotificationFromObject:destination keyPath:keyPath]; + [destination setValue:newValue forKeyPath:keyPath]; + [self unsuppressSpecificNotificationFromObject:destination keyPath:keyPath]; +} + @end @implementation _CPTextFieldPatternValueBinder : CPValueWithPatternBinding