Permalink
Browse files

don't call the delegate if the selection hasn't changed in LPCalendar…

…View
  • Loading branch information...
1 parent 009037d commit c798265220a2f2d0a258abc73e39cce0ad7246eb @luddep luddep committed Jul 28, 2010
Showing with 14 additions and 9 deletions.
  1. +14 −9 LPCalendarView.j
View
23 LPCalendarView.j
@@ -27,7 +27,6 @@
* THE SOFTWARE.
*
*/
-
@import <AppKit/CPControl.j>
@import <LPKit/LPCalendarHeaderView.j>
@import <LPKit/LPCalendarMonthView.j>
@@ -201,6 +200,7 @@
// We can only slide one month in at a time.
if ([slideView isSliding])
return;
+
[self changeToMonth:[currentMonthView previousMonth]];
}
@@ -209,6 +209,7 @@
// We can only slide one month in at a time.
if ([slideView isSliding])
return;
+
[self changeToMonth:[currentMonthView nextMonth]];
}
@@ -219,16 +220,20 @@
- (void)didMakeSelection:(CPArray)aSelection
{
+ // Make sure we have an end to the selection
+ if ([aSelection count] <= 1)
+ [aSelection addObject:nil];
+
+ // The selection didn't change
+ if ([fullSelection isEqualToArray:aSelection])
+ return;
+
+ // Copy the selection
fullSelection = [CPArray arrayWithArray:aSelection];
- if ([fullSelection count] <= 1)
- [fullSelection addObject:nil];
-
- // Keeps any delegate calls from locking up the UI
- setTimeout(function(){
- if ([_delegate respondsToSelector:@selector(calendarView:didMakeSelection:end:)])
- [_delegate calendarView:self didMakeSelection:[fullSelection objectAtIndex:0] end:[fullSelection lastObject]];
- }, 1);
+ // Call the delegate
+ if (_delegate && [_delegate respondsToSelector:@selector(calendarView:didMakeSelection:end:)])
+ [_delegate calendarView:self didMakeSelection:[fullSelection objectAtIndex:0] end:[fullSelection lastObject]];
}
@end

0 comments on commit c798265

Please sign in to comment.