From 2b7726352d1d422d4284618c8762637f64ec9a68 Mon Sep 17 00:00:00 2001 From: Johan Paulsson Date: Sun, 1 Dec 2013 13:23:59 -0800 Subject: osx gui: Fixed dragging of the preview pdf to all applications. --- tikzit/src/osx/DraggablePDFView.m | 18 +++++++++++------- tikzit/src/osx/PreviewController.m | 3 +-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tikzit/src/osx/DraggablePDFView.m b/tikzit/src/osx/DraggablePDFView.m index ce57473..ce393c7 100644 --- a/tikzit/src/osx/DraggablePDFView.m +++ b/tikzit/src/osx/DraggablePDFView.m @@ -38,17 +38,21 @@ - (void)mouseDown:(NSEvent *)theEvent { - NSPasteboard *pboard; - NSRect pageBox = [[[self document] pageAtIndex:0] boundsForBox:kPDFDisplayBoxMediaBox]; NSRect pageRect= [self convertRect:pageBox fromPage:[[self document] pageAtIndex:0]]; - pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; - [pboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypePDF] owner:self]; - [pboard setData:[[self document] dataRepresentation] forType:NSPasteboardTypePDF]; + NSArray *fileList = [NSArray arrayWithObjects:[[[self document] documentURL] path], nil]; + NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + [pboard declareTypes:[NSArray arrayWithObject:NSFilenamesPboardType] owner:nil]; + [pboard setPropertyList:fileList forType:NSFilenamesPboardType]; - [self dragImage:[[NSImage alloc] initWithData:[[self document] dataRepresentation]] at:pageRect.origin offset:pageRect.size - event:theEvent pasteboard:pboard source:self slideBack:YES]; + [self dragImage:[[NSImage alloc] initWithData:[[self document] dataRepresentation]] + at:pageRect.origin + offset:pageRect.size + event:theEvent + pasteboard:pboard + source:self + slideBack:YES]; return; } diff --git a/tikzit/src/osx/PreviewController.m b/tikzit/src/osx/PreviewController.m index 94a80a4..310c2ab 100644 --- a/tikzit/src/osx/PreviewController.m +++ b/tikzit/src/osx/PreviewController.m @@ -109,8 +109,7 @@ static PreviewController *preview = nil; [errorText setString:@""]; [errorTextView setHidden:YES]; - data = [NSData dataWithContentsOfFile:pdfFile]; - PDFDocument *doc = [[PDFDocument alloc] initWithData:data]; + PDFDocument *doc = [[PDFDocument alloc] initWithURL:[[NSURL alloc] initFileURLWithPath:pdfFile]]; // pad the PDF by a couple of pixels if ([doc pageCount] >= 1) { -- cgit v1.2.3