From 5731ad6b3e35ae5a601188c112818a532943484d Mon Sep 17 00:00:00 2001 From: Nimetu Date: Thu, 2 Dec 2021 18:24:49 +0200 Subject: [PATCH] Fix macOS build, utf8 fixes --- nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp | 8 ++++---- nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp b/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp index 834331a3c..4d0b833b3 100644 --- a/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp +++ b/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.cpp @@ -152,7 +152,7 @@ static NLMISC::TKey virtualKeycodeToNelKey(unsigned short keycode) return NLMISC::KeyNOKEY; } -bool CCocoaEventEmitter::pasteTextFromClipboard(ucstring &text) +bool CCocoaEventEmitter::pasteTextFromClipboard(std::string &text) { NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; NSArray *classArray = [NSArray arrayWithObject:[NSString class]]; @@ -163,17 +163,17 @@ bool CCocoaEventEmitter::pasteTextFromClipboard(ucstring &text) { NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options]; NSString *nstext = [objectsToPaste objectAtIndex:0]; - text.fromUtf8([nstext UTF8String]); + text = [nstext UTF8String]; return true; } return false; } -bool CCocoaEventEmitter::copyTextToClipboard(const ucstring &text) +bool CCocoaEventEmitter::copyTextToClipboard(const std::string &text) { NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; [pasteboard clearContents]; - NSArray *copiedObjects = [NSArray arrayWithObject:[NSString stringWithUTF8String:text.toUtf8().c_str()]]; + NSArray *copiedObjects = [NSArray arrayWithObject:[NSString stringWithUTF8String:text.c_str()]]; [pasteboard writeObjects:copiedObjects]; return true; } diff --git a/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h b/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h index 5d3728f3c..e370e0db5 100644 --- a/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h +++ b/nel/src/3d/driver/opengl/mac/cocoa_event_emitter.h @@ -21,6 +21,7 @@ #ifndef NL_COCOA_EVENT_EMITTER_H #define NL_COCOA_EVENT_EMITTER_H +#include #include "nel/misc/event_emitter.h" #include "nel/misc/event_server.h" #include "nel/misc/events.h" @@ -53,8 +54,8 @@ public: virtual void submitEvents(CEventServer& server, bool allWindows); bool handleQuitRequest(); - virtual bool copyTextToClipboard(const ucstring &text); - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); + virtual bool pasteTextFromClipboard(std::string &text); }; }