Re: [w3c/clipboard-apis] What should `clipboard.readText()` return when the clipboard contains multiple clipboard items? (Issue #166)

I augmented the test app a bit so that it instead writes two strings as separate items to the pasteboard, and then queries for just the string on the pasteboard (without specifying an item).

```
int main(int argc, const char * argv[]) {
    __auto_type item1 = [NSPasteboardItem new];
    __auto_type item2 = [NSPasteboardItem new];

    [item1 setString:@"Hello world" forType:NSPasteboardTypeString];
    [item2 setString:@"Foo bar" forType:NSPasteboardTypeString];

    [[NSPasteboard generalPasteboard] clearContents];
    [[NSPasteboard generalPasteboard] writeObjects:@[item1, item2]];

    NSLog(@"The string is: \"%@\"", [[NSPasteboard generalPasteboard] stringForType:NSPasteboardTypeString]);
}
```

…with output:

```
2022-02-02 08:34:44.587825-0800 PasteboardTest[5784:30400159] The string is: "Hello world
Foo bar"
```

So on macOS at least, the platform behavior for the overall text representation when there are multiple items is that it concatenates all the strings together with a newline in between each item.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3c/clipboard-apis/issues/166#issuecomment-1028127806

You are receiving this because you are subscribed to this thread.

Message ID: <w3c/clipboard-apis/issues/166/1028127806@github.com>

Received on Wednesday, 2 February 2022 16:37:21 UTC