Revision: 10205
http://sourceforge.net/p/skim-app/code/10205
Author: hofman
Date: 2018-12-30 13:43:27 +0000 (Sun, 30 Dec 2018)
Log Message:
-----------
drag selected text from secondary pdfview, if in text selection mode
Modified Paths:
--------------
trunk/PDFView_SKExtensions.h
trunk/PDFView_SKExtensions.m
trunk/SKPDFView.m
trunk/SKSecondaryPDFView.m
Modified: trunk/PDFView_SKExtensions.h
===================================================================
--- trunk/PDFView_SKExtensions.h 2018-12-30 13:31:04 UTC (rev 10204)
+++ trunk/PDFView_SKExtensions.h 2018-12-30 13:43:27 UTC (rev 10205)
@@ -57,6 +57,7 @@
- (void)doPdfsyncWithEvent:(NSEvent *)theEvent;
- (void)doDragWithEvent:(NSEvent *)theEvent;
+- (BOOL)doDragTextWithEvent:(NSEvent *)theEvent;
- (PDFPage *)pageAndPoint:(NSPoint *)point forEvent:(NSEvent *)event
nearest:(BOOL)nearest;
Modified: trunk/PDFView_SKExtensions.m
===================================================================
--- trunk/PDFView_SKExtensions.m 2018-12-30 13:31:04 UTC (rev 10204)
+++ trunk/PDFView_SKExtensions.m 2018-12-30 13:43:27 UTC (rev 10205)
@@ -49,6 +49,9 @@
#import "SKStringConstants.h"
#import <SkimNotes/SkimNotes.h>
#import "NSColor_SKExtensions.h"
+#import "SKApplication.h"
+#import "NSView_SKExtensions.h"
+#import "NSImage_SKExtensions.h"
#if SDK_BEFORE(10_7)
@@ -267,6 +270,61 @@
[self performSelector:@selector(mouseMoved:) withObject:theEvent
afterDelay:0];
}
+#pragma mark NSDraggingSource protocol
+
+#if DEPLOYMENT_BEFORE(10_7)
+
+- (void)dragObject:(id<NSPasteboardWriting>)object withImage:(NSImage *)image
fromFrame:(NSRect)frame forEvent:(NSEvent *)event {
+ NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+ [pboard clearContents];
+ [pboard writeObjects:[NSArray arrayWithObjects:object, nil]];
+
+ NSPoint dragPoint = frame.origin;
+ if ([self isFlipped])
+ dragPoint.y += NSHeight(frame);
+
+ [self dragImage:image at:dragPoint offset:NSZeroSize event:event
pasteboard:pboard source:self slideBack:YES];
+}
+
+- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal{
+ return isLocal ? NSDragOperationNone : NSDragOperationCopy;
+}
+
+#else
+
+- (void)dragObject:(id<NSPasteboardWriting>)object withImage:(NSImage *)image
fromFrame:(NSRect)frame forEvent:(NSEvent *)event {
+ NSDraggingItem *dragItem = [[[NSDraggingItem alloc]
initWithPasteboardWriter:object] autorelease];
+ [dragItem setDraggingFrame:frame contents:image];
+ [self beginDraggingSessionWithItems:[NSArray arrayWithObjects:dragItem,
nil] event:event source:self];
+}
+
+- (NSDragOperation)draggingSession:(NSDraggingSession *)session
sourceOperationMaskForDraggingContext:(NSDraggingContext)context {
+ return context == NSDraggingContextWithinApplication ? NSDragOperationNone
: NSDragOperationCopy;
+}
+
+#endif
+
+- (BOOL)doDragTextWithEvent:(NSEvent *)theEvent {
+ if ([[self currentSelection] hasCharacters] == NO)
+ return NO;
+
+ NSPoint point;
+ PDFPage *page = [self pageAndPoint:&point forEvent:theEvent nearest:NO];
+
+ if (page == nil || NSPointInRect(point, [[self currentSelection]
boundsForPage:page]) == NO || [NSApp willDragMouse] == NO)
+ return NO;
+
+ NSImage *dragImage = [NSImage bitmapImageWithSize:NSMakeSize(32.0, 32.0)
scale:[self backingScale] drawingHandler:^(NSRect rect){
+ [[[NSWorkspace sharedWorkspace]
iconForFileType:NSFileTypeForHFSTypeCode(kClippingTextType)] drawInRect:rect
fromRect:rect operation:NSCompositeCopy fraction:RUNNING_BEFORE(10_7) ? 0.8 :
1.0 respectFlipped:YES hints:nil];
+ }];
+
+ NSRect dragFrame = SKRectFromCenterAndSize([theEvent locationInView:self],
[dragImage size]);
+
+ [self dragObject:[[self currentSelection] attributedString]
withImage:dragImage fromFrame:dragFrame forEvent:theEvent];
+
+ return YES;
+}
+
- (PDFPage *)pageAndPoint:(NSPoint *)point forEvent:(NSEvent *)event
nearest:(BOOL)nearest {
NSPoint p = [event locationInView:self];
PDFPage *page = [self pageForPoint:p nearest:nearest];
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2018-12-30 13:31:04 UTC (rev 10204)
+++ trunk/SKPDFView.m 2018-12-30 13:43:27 UTC (rev 10205)
@@ -1711,40 +1711,6 @@
}
}
-#pragma mark NSDraggingSource protocol
-
-#if DEPLOYMENT_BEFORE(10_7)
-
-- (void)dragObject:(id<NSPasteboardWriting>)object withImage:(NSImage *)image
fromFrame:(NSRect)frame forEvent:(NSEvent *)event {
- NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
- [pboard clearContents];
- [pboard writeObjects:[NSArray arrayWithObjects:object, nil]];
-
- NSPoint dragPoint = frame.origin;
- if ([self isFlipped])
- dragPoint.y += NSHeight(frame);
-
- [self dragImage:image at:dragPoint offset:NSZeroSize event:event
pasteboard:pboard source:self slideBack:YES];
-}
-
-- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal{
- return isLocal ? NSDragOperationNone : NSDragOperationCopy;
-}
-
-#else
-
-- (void)dragObject:(id<NSPasteboardWriting>)object withImage:(NSImage *)image
fromFrame:(NSRect)frame forEvent:(NSEvent *)event {
- NSDraggingItem *dragItem = [[[NSDraggingItem alloc]
initWithPasteboardWriter:object] autorelease];
- [dragItem setDraggingFrame:frame contents:image];
- [self beginDraggingSessionWithItems:[NSArray arrayWithObjects:dragItem,
nil] event:event source:self];
-}
-
-- (NSDragOperation)draggingSession:(NSDraggingSession *)session
sourceOperationMaskForDraggingContext:(NSDraggingContext)context {
- return context == NSDraggingContextWithinApplication ? NSDragOperationNone
: NSDragOperationCopy;
-}
-
-#endif
-
#pragma mark NSDraggingDestination protocol
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender {
@@ -4333,27 +4299,6 @@
}
}
-- (BOOL)doDragTextWithEvent:(NSEvent *)theEvent {
- if ([[self currentSelection] hasCharacters] == NO)
- return NO;
-
- NSPoint point;
- PDFPage *page = [self pageAndPoint:&point forEvent:theEvent nearest:NO];
-
- if (page == nil || NSPointInRect(point, [[self currentSelection]
boundsForPage:page]) == NO || [NSApp willDragMouse] == NO)
- return NO;
-
- NSImage *dragImage = [NSImage bitmapImageWithSize:NSMakeSize(32.0, 32.0)
scale:[self backingScale] drawingHandler:^(NSRect rect){
- [[[NSWorkspace sharedWorkspace]
iconForFileType:NSFileTypeForHFSTypeCode(kClippingTextType)] drawInRect:rect
fromRect:rect operation:NSCompositeCopy fraction:RUNNING_BEFORE(10_7) ? 0.8 :
1.0 respectFlipped:YES hints:nil];
- }];
-
- NSRect dragFrame = SKRectFromCenterAndSize([theEvent locationInView:self],
[dragImage size]);
-
- [self dragObject:[[self currentSelection] attributedString]
withImage:dragImage fromFrame:dragFrame forEvent:theEvent];
-
- return YES;
-}
-
- (BOOL)doDragMouseWithEvent:(NSEvent *)theEvent {
BOOL didDrag = NO;;
// eat up mouseDragged/mouseUp events, so we won't get their event handlers
Modified: trunk/SKSecondaryPDFView.m
===================================================================
--- trunk/SKSecondaryPDFView.m 2018-12-30 13:31:04 UTC (rev 10204)
+++ trunk/SKSecondaryPDFView.m 2018-12-30 13:43:27 UTC (rev 10205)
@@ -633,7 +633,7 @@
[self doDragWithEvent:theEvent];
- } else {
+ } else if ([self doDragTextWithEvent:theEvent] == NO) {
[super mouseDown:theEvent];
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