diff --git a/doc/tutorial/15_lolimgui.cpp b/doc/tutorial/15_lolimgui.cpp index 10824603..246fa040 100644 --- a/doc/tutorial/15_lolimgui.cpp +++ b/doc/tutorial/15_lolimgui.cpp @@ -64,7 +64,7 @@ public: ImGui::Text("Scroll: %f", io.MouseWheel); ImGui::Text("Maj: %s", io.KeyShift ? "true" : "false"); ImGui::Text("Ctrl: %s", io.KeyCtrl ? "true" : "false"); - ImGui::Text("Clipboard %s", LolImGui::GetClipboard()); + ImGui::Text("Clipboard %s", LolImGui::GetClipboard().C()); ImGui::InputText("base input", buf, 512); } ImGui::End(); diff --git a/src/3rdparty/imgui b/src/3rdparty/imgui index cb7e1c18..6742ac45 160000 --- a/src/3rdparty/imgui +++ b/src/3rdparty/imgui @@ -1 +1 @@ -Subproject commit cb7e1c18b57092da146307557b3e9d1fead7430f +Subproject commit 6742ac4587de26f9bec2a12cb0b2f33a4d84df94 diff --git a/src/lolimgui.cpp b/src/lolimgui.cpp index 9cea9de0..53c6d87b 100644 --- a/src/lolimgui.cpp +++ b/src/lolimgui.cpp @@ -128,8 +128,9 @@ void LolImGui::Init() //Func pointer io.RenderDrawListsFn = LolImGui::RenderDrawLists; - io.SetClipboardTextFn = LolImGui::SetClipboard; - io.GetClipboardTextFn = LolImGui::GetClipboard; + io.SetClipboardTextFn = LolImGui::SetClipboardCallback; + io.GetClipboardTextFn = LolImGui::GetClipboardCallback; + io.ClipboardUserData = &g_lolimgui->m_clipboard; } /* CALLBACKS @@ -154,14 +155,20 @@ void LolImGui::Shutdown() } //----------------------------------------------------------------------------- -static String g_clipboard; -void LolImGui::SetClipboard(const char* text) +String LolImGui::GetClipboard() { - g_clipboard = text; + return g_lolimgui ? g_lolimgui->m_clipboard : ""; } -const char* LolImGui::GetClipboard() + +void LolImGui::SetClipboardCallback(void *data, const char* text) +{ + String *clipboard = (String *)data; + *clipboard = text; +} +const char* LolImGui::GetClipboardCallback(void *data) { - return g_clipboard.C(); + String *clipboard = (String *)data; + return clipboard->C(); } //----------------------------------------------------------------------------- diff --git a/src/lolimgui.h b/src/lolimgui.h index 1fd3b0b6..5f3ca7fd 100644 --- a/src/lolimgui.h +++ b/src/lolimgui.h @@ -137,13 +137,15 @@ public: static void Shutdown(); //------------------------------------------------------------------------- - static void SetClipboard(const char* text); - static const char* GetClipboard(); + static String GetClipboard(); protected: virtual void TickGame(float seconds); virtual void TickDraw(float seconds, Scene &scene); + static void SetClipboardCallback(void *data, const char* text); + static const char* GetClipboardCallback(void *data); + static void RenderDrawLists(ImDrawData* draw_data); void RenderDrawListsMethod(ImDrawData* draw_data); @@ -172,6 +174,7 @@ protected: InputDevice* m_keyboard = nullptr; InputProfile m_profile; //map m_keys; + String m_clipboard; }; //-----------------------------------------------------------------------------