Skip to content

Commit

Permalink
don't call the delegate if the selection hasn't changed in LPCalendar…
Browse files Browse the repository at this point in the history
…View
  • Loading branch information
luddep committed Jul 28, 2010
1 parent 009037d commit c798265
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions LPCalendarView.j
Expand Up @@ -27,7 +27,6 @@
* THE SOFTWARE.
*
*/

@import <AppKit/CPControl.j>
@import <LPKit/LPCalendarHeaderView.j>
@import <LPKit/LPCalendarMonthView.j>
Expand Down Expand Up @@ -201,6 +200,7 @@
// We can only slide one month in at a time.
if ([slideView isSliding])
return;

[self changeToMonth:[currentMonthView previousMonth]];
}

Expand All @@ -209,6 +209,7 @@
// We can only slide one month in at a time.
if ([slideView isSliding])
return;

[self changeToMonth:[currentMonthView nextMonth]];
}

Expand All @@ -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
Expand Down

0 comments on commit c798265

Please sign in to comment.