23 #import <AppKit/AppKit.h>
24 #import <AvailabilityMacros.h>
25 #import <Foundation/Foundation.h>
32 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
33 NSString*
string = nil;
34 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
36 NSArray* classes = [NSArray arrayWithObjects:[NSString class], nil];
37 NSDictionary* options = [NSDictionary dictionary];
38 NSArray* copiedItems = [pasteboard readObjectsForClasses:classes options:options];
39 if (copiedItems != nil && [copiedItems count] > 0)
41 string = [copiedItems objectAtIndex:0];
46 NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil];
47 if ([pasteboard availableTypeFromArray:types] != nil)
48 string = [pasteboard stringForType:NSStringPboardType];
51 #endif // MAC_OS_X_VERSION_MIN_REQUIRED
54 out = std::string([
string UTF8String]);
65 NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
66 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
67 NSString* type = NSPasteboardTypeString;
68 [pasteboard clearContents];
70 NSString* type = NSStringPboardType;
71 NSArray* types = [NSArray arrayWithObjects: type, nil];
73 [pasteboard declareTypes:types owner:nil];
74 #endif // MAC_OS_X_VERSION_MIN_REQUIRED
77 BOOL ok = [pasteboard setString:[NSString stringWithUTF8String:string.c_str()] forType:type];
C++ interface to Cocoa implementation for pasteboards.
static void out(const wchar_t *fmt,...)
bool osx_GetStringFromPasteboard(std::string &out)
Get a string from the pasteboard.
bool osx_SendStringToPasteboard(const std::string &string)
Store a string on the pasteboard.