Revision: 28297
          http://sourceforge.net/p/bibdesk/svn/28297
Author:   hofman
Date:     2023-06-06 21:25:31 +0000 (Tue, 06 Jun 2023)
Log Message:
-----------
Pass icon index as userData for tooltiprect

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2023-06-06 
17:09:54 UTC (rev 28296)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2023-06-06 
21:25:31 UTC (rev 28297)
@@ -1628,7 +1628,6 @@
         NSPoint mouseLoc = [self convertPoint:[[self window] 
mouseLocationOutsideOfEventStream] fromView:nil];
         NSUInteger mouseIndex = NSNotFound;
         NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | 
NSTrackingActiveInActiveApp;
-        CGFloat textHeight = [self _textHeight];
         
         for (r = rMin, i = iMin; r < rMax; r++) 
         {
@@ -1654,13 +1653,13 @@
                     [area release];
                     
                     // don't pass the URL as owner, as it's not retained; use 
the delegate method instead
-                    [self addToolTipRect:rect owner:self userData:NULL];
+                    [self addToolTipRect:rect owner:self userData:(void *)i];
                 }
                 
-                rect = NSIntersectionRect(visibleRect, 
NSMakeRect(NSMinX(iconRect), NSMaxY(iconRect) + TEXT_OFFSET, NSWidth(iconRect), 
textHeight));
+                rect = NSIntersectionRect(visibleRect, [self 
_rectOfTextForIconRect:iconRect]);
                 
                 if (NSIsEmptyRect(rect) == NO) {
-                    [self addToolTipRect:rect owner:self userData:(void *)1];
+                    [self addToolTipRect:rect owner:self userData:(void *)(i + 
iMax)];
                 }
             }
         }    
@@ -3300,13 +3299,14 @@
 
 - (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag 
point:(NSPoint)point userData:(void *)userData
 {
-    BOOL isTitle = (userData != NULL);
-    if (isTitle) {
-        // shift the point for title toool tips so it falls within its icon 
rect
-        point.y -= TEXT_OFFSET + [self _textHeight];
+    NSUInteger i = (NSUInteger)userData;
+    BOOL isTitle = NO;
+    if (i >= [self numberOfIcons]) {
+        i = i % [self numberOfIcons];
+        isTitle = YES;
     }
     
-    NSURL *theURL = [self _URLAtPoint:point];
+    NSURL *theURL = [self URLAtIndex:i];
     NSString *name = nil;
     if ([theURL isFileURL]) {
         [theURL getResourceValue:&name forKey:NSURLLocalizedNameKey 
error:NULL];
@@ -3316,12 +3316,9 @@
         name = [[theURL absoluteString] 
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
     }
     if (isTitle && [_dataSource 
respondsToSelector:@selector(fileView:subtitleAtIndex:)]) {
-        NSUInteger i = [self _indexAtPoint:point dropOperation:NULL];
-        if (i != NSNotFound) {
-            NSString *subtitle = [self subtitleAtIndex:i];
-            if (subtitle)
-                name = [name stringByAppendingFormat:@"\n%@", subtitle];
-        }
+        NSString *subtitle = [self subtitleAtIndex:i];
+        if (subtitle)
+            name = [name stringByAppendingFormat:@"\n%@", subtitle];
     }
     return name;
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to