Revision: 13520
          http://sourceforge.net/p/skim-app/code/13520
Author:   hofman
Date:     2023-06-29 18:54:47 +0000 (Thu, 29 Jun 2023)
Log Message:
-----------
get mouse location in documentView directly

Modified Paths:
--------------
    trunk/SKPDFView.m

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2023-06-29 17:59:47 UTC (rev 13519)
+++ trunk/SKPDFView.m   2023-06-29 18:54:47 UTC (rev 13520)
@@ -4867,8 +4867,9 @@
 
 
 - (NSRect)doSelectRectWithEvent:(NSEvent *)theEvent didDrag:(BOOL *)didDrag {
-    NSPoint mouseLoc = [theEvent locationInWindow];
-    NSPoint startPoint = [[self documentView] convertPoint:mouseLoc 
fromView:nil];
+    NSView *docView = [self documentView];
+    NSClipView *clipView = [[self scrollView] contentView];
+    NSPoint startPoint = [theEvent locationInView:docView];
     NSPoint currentPoint;
     NSRect selRect = {startPoint, NSZeroSize};
     BOOL dragged = NO;
@@ -4882,17 +4883,15 @@
         if ([theEvent type] == NSEventTypeLeftMouseUp)
             break;
         
+        // dragging or flags changed
+        
         if ([theEvent type] == NSEventTypeLeftMouseDragged) {
             // change mouseLoc
-            [[[self scrollView] contentView] autoscroll:theEvent];
-            mouseLoc = [theEvent locationInWindow];
+            [clipView autoscroll:theEvent];
+            currentPoint = [theEvent locationInView:docView];
             dragged = YES;
         }
         
-        // dragging or flags changed
-        
-        currentPoint = [[self documentView] convertPoint:mouseLoc 
fromView:nil];
-        
         // center around startPoint when holding down the Shift key
         if (([theEvent modifierFlags] & NSEventModifierFlagShift))
             selRect = SKRectFromCenterAndPoint(startPoint, currentPoint);
@@ -4900,9 +4899,9 @@
             selRect = SKRectFromPoints(startPoint, currentPoint);
         
         // intersect with the bounds, project on the bounds if necessary and 
allow zero width or height
-        selRect = SKIntersectionRect(selRect, [[self documentView] bounds]);
+        selRect = SKIntersectionRect(selRect, [docView bounds]);
         
-        [highlightLayerController setRect:[self convertRect:selRect 
fromView:[self documentView]]];
+        [highlightLayerController setRect:[self convertRect:selRect 
fromView:docView]];
         [[highlightLayerController layer] setNeedsDisplay];
     }
     

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



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to