1// Copyright (C) 2005-2006 Etienne Petitjean 2// Copyright (C) 2007-2012 Christian Stehno 3// This file is part of the "Irrlicht Engine". 4// For conditions of distribution and use, see copyright notice in Irrlicht.h 5 6#include "OSXClipboard.h" 7#import <Cocoa/Cocoa.h> 8 9void OSXCopyToClipboard(const char *text) 10{ 11 NSString *str; 12 NSPasteboard *board; 13 14 if ((text != NULL) && (strlen(text) > 0)) 15 { 16 str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding]; 17 board = [NSPasteboard generalPasteboard]; 18 [board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; 19 [board setString:str forType:NSStringPboardType]; 20 } 21} 22 23char* OSXCopyFromClipboard() 24{ 25 NSString* str; 26 NSPasteboard* board; 27 char* result; 28 29 result = NULL; 30 board = [NSPasteboard generalPasteboard]; 31 str = [board stringForType:NSStringPboardType]; 32 if (str != nil) 33 result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding]; 34 return (result); 35} 36 37