Skip to content

Commit

Permalink
Fix potential updateTrackingAreas bug with tooltips and cells
Browse files Browse the repository at this point in the history
  • Loading branch information
Deadpikle committed Aug 26, 2016
1 parent 0891d13 commit 952ca56
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions JNWCollectionView/JNWCollectionViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ - (void)updateLayer {

@interface JNWCollectionViewCell()
@property (nonatomic, strong) JNWCollectionViewCellBackgroundView *backgroundView;
@property (nonatomic, strong) NSTrackingArea *trackingArea;
@end

@implementation JNWCollectionViewCell
Expand Down Expand Up @@ -120,13 +121,13 @@ - (void)didLayoutWithFrame:(CGRect)frame {

- (void)updateTrackingAreas {
[super updateTrackingAreas];
[[self.trackingAreas copy] enumerateObjectsUsingBlock:^(NSTrackingArea * _Nonnull trackingArea, NSUInteger idx, BOOL * _Nonnull stop) {
[self removeTrackingArea:trackingArea];
}];
if (self.trackingArea) {
[self removeTrackingArea:self.trackingArea];
}

NSTrackingAreaOptions options = (NSTrackingActiveAlways | NSTrackingInVisibleRect | NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved);
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[self bounds] options:options owner:self userInfo:nil];
[self addTrackingArea:area];
self.trackingArea = [[NSTrackingArea alloc] initWithRect:[self bounds] options:options owner:self userInfo:nil];
[self addTrackingArea:self.trackingArea];
}

- (NSView *)contentView {
Expand Down

0 comments on commit 952ca56

Please sign in to comment.