From 972c14225bbf63abbf1a1637b0a326ee6ba54193 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Wed, 18 Jun 2014 18:30:29 -0700 Subject: [PATCH 1/5] Fixed: CPDatePicker value is wrong when making a click on the stepper Previously, when making a click on the stepper of a textual CPDatePicker, the intern value of the stepper wasn't updated with the correct value of the CPDatePicker. This occurred when the user changed the dateValue in the delegate methods of the textField. --- AppKit/CPDatePicker/_CPDatePickerTextField.j | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/AppKit/CPDatePicker/_CPDatePickerTextField.j b/AppKit/CPDatePicker/_CPDatePickerTextField.j index e002707ad..bf383bcb8 100644 --- a/AppKit/CPDatePicker/_CPDatePickerTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerTextField.j @@ -133,10 +133,10 @@ var CPZeroKeyCode = 48, return NO; } + #pragma mark - #pragma mark Setter Getter methods - /*! Set the value of the control @param aDateValue */ @@ -145,6 +145,12 @@ var CPZeroKeyCode = 48, var dateValue = [aDateValue copy]; [dateValue _dateWithTimeZone:[_datePicker timeZone]]; [_datePickerElementView setDateValue:dateValue]; + + // This is used to update the value of the stepper + // It's usefull when the user change the dateValue in the delegate for example otherwise the stepper will keep the old value + // We don't call the method objectValue: because we don't want to use the binding system of cappuccino when updating this value + if (_currentTextField) + _stepper._value = parseInt([_currentTextField stringValue]); } /*! Set the widget enabled or not @@ -247,9 +253,9 @@ var CPZeroKeyCode = 48, // This gonna update the dateValue with the binding if (isUp) - [_stepper setDoubleValue:parseInt([_currentTextField objectValue]) + 1]; + [_stepper setDoubleValue:parseInt([_currentTextField stringValue]) + 1]; else - [_stepper setDoubleValue:parseInt([_currentTextField objectValue]) - 1]; + [_stepper setDoubleValue:parseInt([_currentTextField stringValue]) - 1]; return; } @@ -257,7 +263,7 @@ var CPZeroKeyCode = 48, if ([_currentTextField dateType] != CPAMPMDateType) { // Make sure to get the good value, especially when we reach the maxDate or minDate - [sender setDoubleValue:parseInt([_currentTextField objectValue])]; + [sender setDoubleValue:parseInt([_currentTextField stringValue])]; } else { @@ -284,7 +290,7 @@ var CPZeroKeyCode = 48, if (key == CPUpArrowFunctionKey) { [_currentTextField _invalidTimer]; - [_stepper setDoubleValue:parseInt([_currentTextField objectValue])]; + [_stepper setDoubleValue:parseInt([_currentTextField stringValue])]; [_stepper performClickUp:self]; return YES; } @@ -292,7 +298,7 @@ var CPZeroKeyCode = 48, if (key == CPDownArrowFunctionKey) { [_currentTextField _invalidTimer]; - [_stepper setDoubleValue:parseInt([_currentTextField objectValue])]; + [_stepper setDoubleValue:parseInt([_currentTextField stringValue])]; [_stepper performClickDown:self]; return YES; } @@ -1563,6 +1569,7 @@ var CPMonthDateType = 0, [self setStringValue:dateValue.getSeconds().toString()]; return; } + [super setObjectValue:objectValue]; break; From 717841877f4a057736f1f7bc11b7b78e725fcb70 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Sun, 22 Jun 2014 13:18:03 -0700 Subject: [PATCH 2/5] Fixed: typo in _CPDatePickerTextField.j --- AppKit/CPDatePicker/_CPDatePickerTextField.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPDatePicker/_CPDatePickerTextField.j b/AppKit/CPDatePicker/_CPDatePickerTextField.j index bf383bcb8..b94d964ac 100644 --- a/AppKit/CPDatePicker/_CPDatePickerTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerTextField.j @@ -263,7 +263,7 @@ var CPZeroKeyCode = 48, if ([_currentTextField dateType] != CPAMPMDateType) { // Make sure to get the good value, especially when we reach the maxDate or minDate - [sender setDoubleValue:parseInt([_currentTextField stringValue])]; + [sender setDoubleValue:parseInt([_currentTextField stringValue])]; } else { From 96b791b5f951c71efb37c1c6aa5784c7832d85ba Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Mon, 23 Jun 2014 10:28:10 -0700 Subject: [PATCH 3/5] Fixed: fixed gangster's comment --- AppKit/CPDatePicker/_CPDatePickerTextField.j | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/AppKit/CPDatePicker/_CPDatePickerTextField.j b/AppKit/CPDatePicker/_CPDatePickerTextField.j index b94d964ac..1b38ca8ef 100644 --- a/AppKit/CPDatePicker/_CPDatePickerTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerTextField.j @@ -146,9 +146,7 @@ var CPZeroKeyCode = 48, [dateValue _dateWithTimeZone:[_datePicker timeZone]]; [_datePickerElementView setDateValue:dateValue]; - // This is used to update the value of the stepper - // It's usefull when the user change the dateValue in the delegate for example otherwise the stepper will keep the old value - // We don't call the method objectValue: because we don't want to use the binding system of cappuccino when updating this value + // Before sure to update the stepper value. We don't use -setObjectValue to avoid a binding update. if (_currentTextField) _stepper._value = parseInt([_currentTextField stringValue]); } @@ -251,7 +249,7 @@ var CPZeroKeyCode = 48, [self _selectTextField:_firstTextField]; [[self window] makeFirstResponder:_datePicker]; - // This gonna update the dateValue with the binding + // Update the dateValue with the binding. if (isUp) [_stepper setDoubleValue:parseInt([_currentTextField stringValue]) + 1]; else From bc9c78acfe563d5d97b5f199e6310eec411d93a8 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Tue, 24 Jun 2014 10:03:26 -0700 Subject: [PATCH 4/5] Fixed: wrong comment --- AppKit/CPDatePicker/_CPDatePickerTextField.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/CPDatePicker/_CPDatePickerTextField.j b/AppKit/CPDatePicker/_CPDatePickerTextField.j index 1b38ca8ef..17668f8a3 100644 --- a/AppKit/CPDatePicker/_CPDatePickerTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerTextField.j @@ -146,7 +146,7 @@ var CPZeroKeyCode = 48, [dateValue _dateWithTimeZone:[_datePicker timeZone]]; [_datePickerElementView setDateValue:dateValue]; - // Before sure to update the stepper value. We don't use -setObjectValue to avoid a binding update. + // Be sure to update the stepper value. We don't use -setObjectValue to avoid a binding update. if (_currentTextField) _stepper._value = parseInt([_currentTextField stringValue]); } From 34072f3947660545ca987704e992891c38ba6b00 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Tue, 24 Jun 2014 16:53:31 -0700 Subject: [PATCH 5/5] Fixed: stringValue is used instead of intValue --- AppKit/CPDatePicker/_CPDatePickerTextField.j | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/AppKit/CPDatePicker/_CPDatePickerTextField.j b/AppKit/CPDatePicker/_CPDatePickerTextField.j index 17668f8a3..0429c5752 100644 --- a/AppKit/CPDatePicker/_CPDatePickerTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerTextField.j @@ -148,7 +148,7 @@ var CPZeroKeyCode = 48, // Be sure to update the stepper value. We don't use -setObjectValue to avoid a binding update. if (_currentTextField) - _stepper._value = parseInt([_currentTextField stringValue]); + _stepper._value = [_currentTextField intValue]; } /*! Set the widget enabled or not @@ -221,7 +221,7 @@ var CPZeroKeyCode = 48, if ([_currentTextField dateType] != CPAMPMDateType) { // We update the value of the stepper dependind on the textField - [_stepper setObjectValue:parseInt([_currentTextField stringValue])]; + [_stepper setObjectValue:[_currentTextField intValue]]; [_stepper setMaxValue:[_currentTextField maxNumber]]; [_stepper setMinValue:[_currentTextField minNumber]]; @@ -251,9 +251,9 @@ var CPZeroKeyCode = 48, // Update the dateValue with the binding. if (isUp) - [_stepper setDoubleValue:parseInt([_currentTextField stringValue]) + 1]; + [_stepper setDoubleValue:[_currentTextField intValue] + 1]; else - [_stepper setDoubleValue:parseInt([_currentTextField stringValue]) - 1]; + [_stepper setDoubleValue:[_currentTextField intValue] - 1]; return; } @@ -261,7 +261,7 @@ var CPZeroKeyCode = 48, if ([_currentTextField dateType] != CPAMPMDateType) { // Make sure to get the good value, especially when we reach the maxDate or minDate - [sender setDoubleValue:parseInt([_currentTextField stringValue])]; + [sender setDoubleValue:[_currentTextField intValue]]; } else { @@ -288,7 +288,7 @@ var CPZeroKeyCode = 48, if (key == CPUpArrowFunctionKey) { [_currentTextField _invalidTimer]; - [_stepper setDoubleValue:parseInt([_currentTextField stringValue])]; + [_stepper setDoubleValue:[_currentTextField intValue]]; [_stepper performClickUp:self]; return YES; } @@ -296,7 +296,7 @@ var CPZeroKeyCode = 48, if (key == CPDownArrowFunctionKey) { [_currentTextField _invalidTimer]; - [_stepper setDoubleValue:parseInt([_currentTextField stringValue])]; + [_stepper setDoubleValue:[_currentTextField intValue]]; [_stepper performClickDown:self]; return YES; } @@ -597,23 +597,23 @@ var CPZeroKeyCode = 48, [date _dateWithTimeZone:[_datePicker timeZone]]; if (![_textFieldDay isHidden]) - date.setDate([_textFieldDay stringValue]); + date.setDate([_textFieldDay intValue]); if (![_textFieldMonth isHidden]) - date.setMonth(parseInt([_textFieldMonth stringValue]) - 1); + date.setMonth([_textFieldMonth intValue] - 1); if (![_textFieldYear isHidden]) - date.setFullYear([_textFieldYear stringValue]); + date.setFullYear([_textFieldYear intValue]); if (![_textFieldSecond isHidden]) - date.setSeconds([_textFieldSecond stringValue]); + date.setSeconds([_textFieldSecond intValue]); if (![_textFieldMinute isHidden]) - date.setMinutes([_textFieldMinute stringValue]); + date.setMinutes([_textFieldMinute intValue]); if (![_textFieldHour isHidden]) { - var hour = parseInt([_textFieldHour stringValue]), + var hour = [_textFieldHour intValue], currentHour = parseInt(date.getHours()); if (hour != currentHour)