Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

extract trackingrect setup to separate method

  • Loading branch information...
commit f298fcd44fb831c0859f3fba35a9bdd1155178a2 1 parent c5bde0a
Zachary Schneirov authored
Showing with 12 additions and 3 deletions.
  1. +2 −0  DualField.h
  2. +10 −3 DualField.m
View
2  DualField.h
@@ -33,6 +33,8 @@ enum { BUTTON_HIDDEN, BUTTON_NORMAL, BUTTON_PRESSED };
BOOL showsDocumentIcon;
}
+- (void)setTrackingRect;
+
- (void)setShowsDocumentIcon:(BOOL)showsIcon;
- (BOOL)showsDocumentIcon;
View
13 DualField.m
@@ -111,8 +111,9 @@ - (void)setShowsSnapbackButton:(BOOL)shouldShow {
- (BOOL)handleMouseDown:(NSEvent *)theEvent {
DualField *controlView = (DualField *)[self controlView];
- if (![self clearButtonIsVisible] && ![self snapbackButtonIsVisible])
+ if (![self clearButtonIsVisible] && ![self snapbackButtonIsVisible]) {
return NO;
+ }
do {
NSPoint mouseLoc = [controlView convertPoint:[theEvent locationInWindow] fromView:nil];
@@ -187,8 +188,12 @@ - (void)awakeFromNib {
[myCell setAllowsUndo:NO];
[myCell setLineBreakMode:NSLineBreakByCharWrapping];
-
- docIconRectTag = [self addTrackingRect:[[self cell] snapbackButtonRectForBounds:[self bounds]] owner:self userData:NULL assumeInside:NO];
+}
+
+- (void)setTrackingRect {
+ if (!docIconRectTag)
+ docIconRectTag = [self addTrackingRect:[[self cell] snapbackButtonRectForBounds:[self bounds]]
+ owner:self userData:NULL assumeInside:NO];
}
- (void)dealloc {
@@ -227,6 +232,8 @@ - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPo
- (void)mouseEntered:(NSEvent *)theEvent {
if ([theEvent trackingNumber] == docIconRectTag) {
[[self cell] setShowsSnapbackButton:[self showsDocumentIcon]];
+ } else {
+ NSLog(@"got mouse entered on a different tracking number: %d", [theEvent trackingNumber]);
}
}
- (void)mouseExited:(NSEvent *)theEvent {
Please sign in to comment.
Something went wrong with that request. Please try again.