- From: Wenson Hsieh <notifications@github.com>
- Date: Wed, 02 Feb 2022 08:29:11 -0800
- To: w3c/clipboard-apis <clipboard-apis@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/clipboard-apis/issues/166/1028120312@github.com>
I wrote a quick Objective-C program to dump pasteboard items (and the list of types per item), and tested it out in a couple of scenarios:
```
@import AppKit;
@import UniformTypeIdentifiers;
int main(int argc, const char * argv[]) {
__auto_type filterDeclaredTypes = [NSPredicate predicateWithBlock:^BOOL(NSString *typeIdentifier, NSDictionary<NSString *,id> *unused) {
return [UTType typeWithIdentifier:typeIdentifier].declared;
}];
[[[NSPasteboard generalPasteboard] pasteboardItems] enumerateObjectsUsingBlock:^(NSPasteboardItem *item, NSUInteger index, BOOL *unused) {
NSLog(@"Item at index [%zu] contains types: %@", index, [item.types filteredArrayUsingPredicate:filterDeclaredTypes]);
}];
}
```
When copying 3 files in Finder, I see multiple items (though only the first item has a plain text representation that contains a space-separated list of file paths):
```
2022-02-02 08:26:30.567 PasteboardTest[5673:30388857] Item at index [0] contains types: (
"public.file-url",
"public.utf16-external-plain-text",
"public.utf8-plain-text"
)
2022-02-02 08:26:30.567 PasteboardTest[5673:30388857] Item at index [1] contains types: (
"public.file-url"
)
2022-02-02 08:26:30.567 PasteboardTest[5673:30388857] Item at index [2] contains types: (
"public.file-url"
)
2022-02-02 08:26:30.568 PasteboardTest[5673:30388857] Item at index [3] contains types: (
"public.file-url"
)
```
When copying 3 images from the Photos app, all 3 items correspond to pasteboard items:
```
2022-02-02 08:27:59.027 PasteboardTest[5678:30390067] Item at index [0] contains types: (
"com.apple.photos.object-reference.asset",
"public.jpeg",
"public.file-url"
)
2022-02-02 08:27:59.028 PasteboardTest[5678:30390067] Item at index [1] contains types: (
"com.apple.photos.object-reference.asset",
"public.jpeg",
"public.file-url"
)
2022-02-02 08:27:59.028 PasteboardTest[5678:30390067] Item at index [2] contains types: (
"com.apple.photos.object-reference.asset",
"public.jpeg",
"public.file-url"
)
```
--
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/166#issuecomment-1028120312
You are receiving this because you are subscribed to this thread.
Message ID: <w3c/clipboard-apis/issues/166/1028120312@github.com>
Received on Wednesday, 2 February 2022 16:29:24 UTC