From 79ec12e2a2f2b935b1d3f448833a4d898c07c9b4 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Mon, 28 Mar 2011 18:02:52 -0400 Subject: [PATCH] Added support for the CPNullPlaceholderBindingOption for bound text fields. --- AppKit/CPKeyValueBinding.j | 3 ++- AppKit/CPObjectController.j | 5 ++++- AppKit/CPTextField.j | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/AppKit/CPKeyValueBinding.j b/AppKit/CPKeyValueBinding.j index 641381b7b..6113880b8 100644 --- a/AppKit/CPKeyValueBinding.j +++ b/AppKit/CPKeyValueBinding.j @@ -430,6 +430,7 @@ CPOptionsKey = @"CPOptionsKey"; CPMultipleValuesMarker = @"CPMultipleValuesMarker"; CPNoSelectionMarker = @"CPNoSelectionMarker"; CPNotApplicableMarker = @"CPNotApplicableMarker"; +CPNullMarker = @"CPNullMarker"; // Binding name constants CPAlignmentBinding = @"alignment"; @@ -470,5 +471,5 @@ CPValueTransformerBindingOption = @"CPValueTransformer"; CPIsControllerMarker = function(/*id*/anObject) { - return anObject === CPMultipleValuesMarker || anObject === CPNoSelectionMarker || anObject === CPNotApplicableMarker; + return anObject === CPMultipleValuesMarker || anObject === CPNoSelectionMarker || anObject === CPNotApplicableMarker || anObject === CPNullMarker; } \ No newline at end of file diff --git a/AppKit/CPObjectController.j b/AppKit/CPObjectController.j index d809d06ed..476c3fff5 100644 --- a/AppKit/CPObjectController.j +++ b/AppKit/CPObjectController.j @@ -663,7 +663,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo - (id)_controllerMarkerForValues:(CPArray)theValues { - var count = [theValues count]; + var count = [theValues count]; if (!count) value = CPNoSelectionMarker; @@ -685,6 +685,9 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo } } + if (value === nil || value.isa && [value isEqual:[CPNull null]]) + value = CPNullMarker; + return value; } diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 44a64eb93..9bcdc8103 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1404,6 +1404,10 @@ var CPTextFieldIsEditableKey = "CPTextFieldIsEditableKey", newValue = [options objectForKey:CPNotApplicablePlaceholderBindingOption] || @"Not Applicable"; break; + + case CPNullMarker: + newValue = [options objectForKey:CPNullPlaceholderBindingOption] || @""; + break; } [_source setPlaceholderString:newValue];