From c1e89bd1c3d27c6c04afa38ab64fe12d93f10c2b Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Fri, 5 Sep 2014 16:16:46 -0700 Subject: [PATCH] Fixed: CPDatePicker in a CPTableView wrong behavior Previously, when clicking on a CPDatePicker in a CPTableView, cappuccino didn't select the tableView row firstly. Now it does as in cocoa. The stepper still have the same behavior as a CPButton in a CPTableView. refs #2201 --- AppKit/CPDatePicker/_CPDatePickerTextField.j | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/AppKit/CPDatePicker/_CPDatePickerTextField.j b/AppKit/CPDatePicker/_CPDatePickerTextField.j index 37780ef43..85ea5a45f 100644 --- a/AppKit/CPDatePicker/_CPDatePickerTextField.j +++ b/AppKit/CPDatePicker/_CPDatePickerTextField.j @@ -533,9 +533,13 @@ var CPZeroKeyCode = 48, #pragma mark - #pragma mark Responder methods +/*! @ignore */ - (BOOL)acceptsFirstResponder { - return NO; + // This is needed to accept to be firstResponder when nothing is selected. + // This element needs to be first responder when the CPDatePicker is in the CPTableView + // When clicking on a row of a CPTableView where there isn't a date element, the CPTableView will ask this element to know if it can becomes or not a firstResponder. + return [_datePicker isEnabled] && ![self superview]._currentTextField; } @@ -1282,6 +1286,12 @@ var CPMonthDateType = 0, return self; } +/*! @ignore */ +- (BOOL)acceptsFirstResponder +{ + return [_datePicker isEnabled]; +} + /*! Set the dateType of the textField */ - (void)setDateType:(int)aDateType @@ -1734,4 +1744,9 @@ var CPMonthDateType = 0, return frameSize; } -@end +- (CGRect)bezelRectForBounds:(CGRect)bounds +{ + return CGRectMakeCopy(bounds); +} + +@end \ No newline at end of file