Revision: 27730
http://sourceforge.net/p/bibdesk/svn/27730
Author: hofman
Date: 2022-07-13 17:57:32 +0000 (Wed, 13 Jul 2022)
Log Message:
-----------
write URLs also as string to pasteboard
Modified Paths:
--------------
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.h
trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2022-07-13
17:15:37 UTC (rev 27729)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m 2022-07-13
17:57:32 UTC (rev 27730)
@@ -2798,7 +2798,7 @@
{
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard clearContents];
- if (NO == [pboard writeObjects:[self _selectedURLs]])
+ if (NO == FVWriteURLsToPasteboard(pboard, [self _selectedURLs]))
return;
NSUInteger r, c, cMin = NSUIntegerMax, cMax = 0, rMin = NSUIntegerMax,
rMax = 0;
@@ -3870,8 +3870,7 @@
- (IBAction)copy:(id)sender;
{
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
- [pboard clearContents];
- if (NO == [pboard writeObjects:[self _selectedURLs]])
+ if (NO == FVWriteURLsToPasteboard(pboard, [self _selectedURLs]))
NSBeep();
}
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.h
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.h 2022-07-13
17:15:37 UTC (rev 27729)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.h 2022-07-13
17:57:32 UTC (rev 27730)
@@ -61,13 +61,17 @@
FV_PRIVATE_EXTERN void FVLog(NSString *format, ...);
/** @internal
- Checks the pasteboard for any URL data. Converts an NSPasteboard to a Carbon
PasteboardRef.
- @param pboard Any NSPasteboard instance.
+ Writes URLs to the pasteboard after clearing pboard. Also writes the
absolute string as string type.
+ @return YES if the data is successfully written to pboard. */
+FV_PRIVATE_EXTERN BOOL FVWriteURLsToPasteboard(NSPasteboard *pboard, NSArray
*urls);
+
+/** @internal
+ Checks the pasteboard for any URL data.
@return YES if pboard has a URL type or a string that can be converted to a
URL. */
FV_PRIVATE_EXTERN BOOL FVPasteboardHasURL(NSPasteboard *pboard);
/** @internal
- Reads URLs from the pasteboard, whether file: or other scheme. Finder puts
multiple URLs on the pasteboard, and also webloc files. Converts an
NSPasteboard to a Carbon PasteboardRef in order to work around NSPasteboard's
terrible URL support.
+ Reads URLs from the pasteboard, whether file: or other scheme. Finder puts
multiple URLs on the pasteboard, and also webloc files.
@param pboard Any NSPasteboard instance.
@return An array of URLs from the pasteboard. */
FV_PRIVATE_EXTERN NSArray *FVURLsFromPasteboard(NSPasteboard *pboard);
Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m 2022-07-13
17:15:37 UTC (rev 27729)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVUtilities.m 2022-07-13
17:57:32 UTC (rev 27730)
@@ -118,6 +118,19 @@
#pragma mark Pasteboard URL functions
+BOOL FVWriteURLsToPasteboard(NSPasteboard *pboard, NSArray *urls)
+{
+ NSMutableArray *items = [NSMutableArray array];
+ for (NSURL *url in urls) {
+ NSPasteboardItem *item = [[NSPasteboardItem alloc] init];
+ NSString *string = [url absoluteString];
+ [item setString:string forType:(NSString *)([url isFileURL] ?
kUTTypeFileURL : kUTTypeURL)];
+ [item setString:string forType:NSPasteboardTypeString];
+ }
+ [pboard clearContents];
+ return [pboard writeObjects:items];
+}
+
BOOL FVPasteboardHasURL(NSPasteboard *pboard)
{
if ([pboard canReadObjectForClasses:[NSArray arrayWithObject:[NSURL
class]] options:nil])
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