Commit ed763437 authored by mercury233's avatar mercury233

fix mac copy&paste

parent 65663132
.DS_Store
/source/Irrlicht/MacOSX/build
......@@ -7,8 +7,8 @@
extern "C" {
#endif
void OSXCopyToClipboard(const char *text);
char* OSXCopyFromClipboard();
void OSXCopyToClipboard(const wchar_t *text);
wchar_t* OSXCopyFromClipboard();
#ifdef __cplusplus
}
......
......@@ -3,34 +3,35 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h
#include "irrString.h"
#include "OSXClipboard.h"
#import <Cocoa/Cocoa.h>
void OSXCopyToClipboard(const char *text)
void OSXCopyToClipboard(const wchar_t *text)
{
NSString *str;
NSPasteboard *board;
if ((text != NULL) && (strlen(text) > 0))
if ((text != NULL) && (wcslen(text) > 0))
{
str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding];
str = [[NSString alloc] initWithBytes:text length:wcslen(text)*sizeof(*text) encoding:NSUTF32LittleEndianStringEncoding];
board = [NSPasteboard generalPasteboard];
[board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp];
[board setString:str forType:NSStringPboardType];
}
}
char* OSXCopyFromClipboard()
wchar_t* OSXCopyFromClipboard()
{
NSString* str;
NSPasteboard* board;
char* result;
wchar_t* result;
result = NULL;
board = [NSPasteboard generalPasteboard];
str = [board stringForType:NSStringPboardType];
if (str != nil)
result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
result = (wchar_t*)[str cStringUsingEncoding:NSUTF32LittleEndianStringEncoding];
return (result);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment