Forum Navigation
You need to log in to create posts and topics.

String to Clipboard

Posted by: kshmidheiser <kshmidheiser@...>

Here's a little snippet that copies a string to the Clipboard.

Ken

BeginCCode
void StringToClipboard( CFStringRef stringToPaste ) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[[NSPasteboard generalPasteboard] declareTypes:[NSArray
arrayWithObject: NSStringPboardType] owner:nil];
[[NSPasteboard generalPasteboard] setString:(NSString *)stringToPaste
forType: NSStringPboardType];
[pool drain];
}
EndC
toolbox fn StringToClipboard( CFStringRef stringToPaste ) = int

fn StringToClipboard( @"This is a test string to copy to Clipboard" )

RunApplicationEventLoop()