Created
June 13, 2012 12:39
-
-
Save TomLiu/2923820 to your computer and use it in GitHub Desktop.
NSCell with checkbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)frame ofView:(NSView *)controlView { | |
NSRect checkBoxFrame = [self _checkBoxFrameForInteriorFrame:frame]; | |
NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil]; | |
// Delegate hit testing to other cells | |
if (_checkBoxCell) { | |
if (NSPointInRect(point, checkBoxFrame)) { | |
return NSCellHitTrackableArea; | |
} | |
} | |
return NSCellHitNone; | |
} | |
+ (BOOL)prefersTrackingUntilMouseUp { | |
// you want a single, long tracking "session" from mouse down till up | |
return YES; | |
} | |
- (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView { | |
[_checkBoxCell setHighlighted:YES]; | |
return YES; // keep tracking | |
} | |
- (BOOL)continueTracking:(NSPoint)lastPoint at:(NSPoint)currentPoint inView:(NSView *)controlView { | |
// if |currentPoint| is in the button, highlight it | |
// otherwise, unhighlight it | |
return YES; // keep on tracking | |
} | |
- (void)stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag { | |
// if |flag| and mouse in button's rect, then | |
// and, finally, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment