IO: (BREAKING) moved io.GetClipboardTextFn, io.SetClipboardTextFn to platform_io.Platform_GetClipboardTextFn, platform_io.Platform_SetClipboardTextFn.
diff --git a/backends/imgui_impl_allegro5.cpp b/backends/imgui_impl_allegro5.cpp
index db366fa..e41f021 100644
--- a/backends/imgui_impl_allegro5.cpp
+++ b/backends/imgui_impl_allegro5.cpp
@@ -20,6 +20,9 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
+// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
+// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
// 2022-11-30: Renderer: Restoring using al_draw_indexed_prim() when Allegro version is >= 5.2.5.
// 2022-10-11: Using 'nullptr' instead of 'NULL' as per our switch to C++11.
// 2022-09-26: Inputs: Renamed ImGuiKey_ModXXX introduced in 1.87 to ImGuiMod_XXX (old names still supported).
@@ -291,7 +294,7 @@
}
#if ALLEGRO_HAS_CLIPBOARD
-static const char* ImGui_ImplAllegro5_GetClipboardText(void*)
+static const char* ImGui_ImplAllegro5_GetClipboardText(ImGuiContext*)
{
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
if (bd->ClipboardTextData)
@@ -300,7 +303,7 @@
return bd->ClipboardTextData;
}
-static void ImGui_ImplAllegro5_SetClipboardText(void*, const char* text)
+static void ImGui_ImplAllegro5_SetClipboardText(ImGuiContext*, const char* text)
{
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
al_set_clipboard_text(bd->Display, text);
@@ -447,9 +450,9 @@
bd->VertexDecl = al_create_vertex_decl(elems, sizeof(ImDrawVertAllegro));
#if ALLEGRO_HAS_CLIPBOARD
- io.SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
- io.ClipboardUserData = nullptr;
+ ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
+ platform_io.Platform_SetClipboardTextFn = ImGui_ImplAllegro5_SetClipboardText;
+ platform_io.Platform_GetClipboardTextFn = ImGui_ImplAllegro5_GetClipboardText;
#endif
return true;
diff --git a/backends/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp
index 7763967..66b71c5 100644
--- a/backends/imgui_impl_glfw.cpp
+++ b/backends/imgui_impl_glfw.cpp
@@ -20,7 +20,9 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
-// 2024-08-22: Follow up on function pointers moved from ImGuiIO to ImGuiPlatformIO:
+// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
+// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
+// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
// - io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn
// 2024-07-31: Added ImGui_ImplGlfw_Sleep() helper function for usage by our examples app, since GLFW doesn't provide one.
// 2024-07-08: *BREAKING* Renamed ImGui_ImplGlfw_InstallEmscriptenCanvasResizeCallback to ImGui_ImplGlfw_InstallEmscriptenCallbacks(), added GLFWWindow* parameter.
diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm
index 30f4ab2..870038d 100644
--- a/backends/imgui_impl_osx.mm
+++ b/backends/imgui_impl_osx.mm
@@ -29,7 +29,9 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
-// 2024-08-22: Follow up on function pointers moved from ImGuiIO to ImGuiPlatformIO:
+// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
+// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
+// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
// 2024-07-02: Update for io.SetPlatformImeDataFn() -> io.PlatformSetImeDataFn() renaming in main library.
// 2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F20 function keys. Stopped mapping F13 into PrintScreen.
@@ -395,6 +397,7 @@
bool ImGui_ImplOSX_Init(NSView* view)
{
ImGuiIO& io = ImGui::GetIO();
+ ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
IMGUI_CHECKVERSION();
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
@@ -425,14 +428,14 @@
// Note that imgui.cpp also include default OSX clipboard handlers which can be enabled
// by adding '#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS' in imconfig.h and adding '-framework ApplicationServices' to your linker command-line.
// Since we are already in ObjC land here, it is easy for us to add a clipboard handler using the NSPasteboard api.
- io.SetClipboardTextFn = [](void*, const char* str) -> void
+ platform_io.Platform_SetClipboardTextFn = [](ImGuiContext*, const char* str) -> void
{
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
[pasteboard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
[pasteboard setString:[NSString stringWithUTF8String:str] forType:NSPasteboardTypeString];
};
- io.GetClipboardTextFn = [](void*) -> const char*
+ platform_io.Platform_GetClipboardTextFn = [](ImGuiContext*) -> const char*
{
NSPasteboard* pasteboard = [NSPasteboard generalPasteboard];
NSString* available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:NSPasteboardTypeString]];
@@ -467,7 +470,6 @@
[view addSubview:bd->KeyEventResponder];
ImGui_ImplOSX_AddTrackingArea(view);
- ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_SetImeDataFn = [](ImGuiContext*, ImGuiViewport* viewport, ImGuiPlatformImeData* data) -> void
{
ImGui_ImplOSX_Data* bd = ImGui_ImplOSX_GetBackendData();
diff --git a/backends/imgui_impl_sdl2.cpp b/backends/imgui_impl_sdl2.cpp
index c30fe6d..b1cc8c9 100644
--- a/backends/imgui_impl_sdl2.cpp
+++ b/backends/imgui_impl_sdl2.cpp
@@ -21,7 +21,9 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
-// 2024-08-22: Follow up on function pointers moved from ImGuiIO to ImGuiPlatformIO:
+// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
+// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
+// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
// - io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
// 2024-08-19: Storing SDL's Uint32 WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
@@ -146,7 +148,7 @@
}
// Functions
-static const char* ImGui_ImplSDL2_GetClipboardText(void*)
+static const char* ImGui_ImplSDL2_GetClipboardText(ImGuiContext*)
{
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
if (bd->ClipboardTextData)
@@ -155,7 +157,7 @@
return bd->ClipboardTextData;
}
-static void ImGui_ImplSDL2_SetClipboardText(void*, const char* text)
+static void ImGui_ImplSDL2_SetClipboardText(ImGuiContext*, const char* text)
{
SDL_SetClipboardText(text);
}
@@ -462,9 +464,9 @@
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
- io.SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
- io.ClipboardUserData = nullptr;
+ platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL2_SetClipboardText;
+ platform_io.Platform_GetClipboardTextFn = ImGui_ImplSDL2_GetClipboardText;
+ platform_io.Platform_ClipboardUserData = nullptr;
platform_io.Platform_SetImeDataFn = ImGui_ImplSDL2_PlatformSetImeData;
#ifdef __EMSCRIPTEN__
platform_io.Platform_OpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplSDL2_EmscriptenOpenURL(url); return true; };
diff --git a/backends/imgui_impl_sdl3.cpp b/backends/imgui_impl_sdl3.cpp
index 37ab21c..deb8c79 100644
--- a/backends/imgui_impl_sdl3.cpp
+++ b/backends/imgui_impl_sdl3.cpp
@@ -21,7 +21,9 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
-// 2024-08-22: Follow up on function pointers moved from ImGuiIO to ImGuiPlatformIO:
+// 2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
+// - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
+// - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
// - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
// 2024-08-19: Storing SDL_WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
// 2024-08-19: ImGui_ImplSDL3_ProcessEvent() now ignores events intended for other SDL windows. (#7853)
@@ -118,7 +120,7 @@
}
// Functions
-static const char* ImGui_ImplSDL3_GetClipboardText(void*)
+static const char* ImGui_ImplSDL3_GetClipboardText(ImGuiContext*)
{
ImGui_ImplSDL3_Data* bd = ImGui_ImplSDL3_GetBackendData();
if (bd->ClipboardTextData)
@@ -128,7 +130,7 @@
return bd->ClipboardTextData;
}
-static void ImGui_ImplSDL3_SetClipboardText(void*, const char* text)
+static void ImGui_ImplSDL3_SetClipboardText(ImGuiContext*, const char* text)
{
SDL_SetClipboardText(text);
}
@@ -457,9 +459,8 @@
bd->MouseCanUseGlobalState = mouse_can_use_global_state;
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
- io.SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
- io.GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
- io.ClipboardUserData = nullptr;
+ platform_io.Platform_SetClipboardTextFn = ImGui_ImplSDL3_SetClipboardText;
+ platform_io.Platform_GetClipboardTextFn = ImGui_ImplSDL3_GetClipboardText;
platform_io.Platform_SetImeDataFn = ImGui_ImplSDL3_PlatformSetImeData;
// Gamepad handling
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index a061e71..25cd2b8 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -41,10 +41,18 @@
Breaking changes:
-- IO: moved some functions from ImGuiIO to ImGuiPlatformIO:
- - io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn. (#7660)
- - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn.
- - io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint. (#7389, #6719, #2278)
+- IO: moved clipboard functions from ImGuiIO to ImGuiPlatformIO:
+ - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn
+ - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn
+ - in function signatures, changed 'void* user_data' to 'ImGuiContext* ctx' for consistency
+ with other functions. Pull your user data from platform_io.ClipboardUserData if used.
+ - as this is will affect all users of custom engines/backends, we are providing proper
+ legacy redirection (will obsolete).
+- IO: moved other functions from ImGuiIO to ImGuiPlatformIO:
+ - io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn (#7660)
+ - io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
+ - io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint (#7389, #6719, #2278)
+ - clipboard function signature changed:
- access those via GetPlatformIO() instead of GetIO().
(Because PlatformOpenInShellFn and PlatformSetImeDataFn were introduced very recently and
often automatically set by core library and backends, we are exceptionally not maintaining
@@ -76,6 +84,8 @@
- Backends: SDL2, SDL3: storing SDL_WindowID inside ImGuiViewport::PlatformHandle instead of SDL_Window*.
- Backends: GLFW: passing null window to glfwGetClipboardString()/glfwSetClipboardString()
since GLFW own tests are doing that and it seems unnecessary.
+- Backends: SDL2, SDL3, GLFW, OSX, Allegro: update to set function handlers in ImGuiPlatformIO
+ instead of ImGuiIO.
- Examples: GLFW (all), SDL2 (all), SDL3 (all), Win32+OpenGL3: rework examples main loop
to handle minimization without burning CPU or GPU by running unthrottled code. (#7844)
diff --git a/imgui.cpp b/imgui.cpp
index deed853..381ffb2 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -431,6 +431,8 @@
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
- 2024/08/22 (1.91.1) - moved some functions from ImGuiIO to ImGuiPlatformIO structure:
+ - io.GetClipboardTextFn -> platform_io.Platform_GetClipboardTextFn + changed 'void* user_data' to 'ImGuiContext* ctx'. Pull your user data from platform_io.ClipboardUserData.
+ - io.SetClipboardTextFn -> platform_io.Platform_SetClipboardTextFn + same as above line.
- io.PlatformOpenInShellFn -> platform_io.Platform_OpenInShellFn (#7660)
- io.PlatformSetImeDataFn -> platform_io.Platform_SetImeDataFn
- io.PlatformLocaleDecimalPoint -> platform_io.Platform_LocaleDecimalPoint (#7389, #6719, #2278)
@@ -1146,9 +1148,9 @@
static void WindowSettingsHandler_ApplyAll(ImGuiContext*, ImGuiSettingsHandler*);
static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSettingsHandler*, ImGuiTextBuffer* buf);
-// Platform Dependents default implementation for IO functions
-static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx);
-static void SetClipboardTextFn_DefaultImpl(void* user_data_ctx, const char* text);
+// Platform Dependents default implementation for ImGuiPlatformIO functions
+static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx);
+static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext* ctx, const char* text);
static void Platform_SetImeDataFn_DefaultImpl(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
static bool Platform_OpenInShellFn_DefaultImpl(ImGuiContext* ctx, const char* path);
@@ -3806,10 +3808,9 @@
// Setup default localization table
LocalizeRegisterEntries(GLocalizationEntriesEnUS, IM_ARRAYSIZE(GLocalizationEntriesEnUS));
- // Setup default platform clipboard/IME handlers.
- g.IO.GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
- g.IO.SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
- g.IO.ClipboardUserData = (void*)&g; // Default implementation use the ImGuiContext as user data (ideally those would be arguments to the function)
+ // Setup default ImGuiPlatformIO clipboard/IME handlers.
+ g.PlatformIO.Platform_GetClipboardTextFn = Platform_GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
+ g.PlatformIO.Platform_SetClipboardTextFn = Platform_SetClipboardTextFn_DefaultImpl;
g.PlatformIO.Platform_OpenInShellFn = Platform_OpenInShellFn_DefaultImpl;
g.PlatformIO.Platform_SetImeDataFn = Platform_SetImeDataFn_DefaultImpl;
@@ -4451,14 +4452,14 @@
const char* ImGui::GetClipboardText()
{
ImGuiContext& g = *GImGui;
- return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : "";
+ return g.PlatformIO.Platform_GetClipboardTextFn ? g.PlatformIO.Platform_GetClipboardTextFn(&g) : "";
}
void ImGui::SetClipboardText(const char* text)
{
ImGuiContext& g = *GImGui;
- if (g.IO.SetClipboardTextFn)
- g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text);
+ if (g.PlatformIO.Platform_SetClipboardTextFn != NULL)
+ g.PlatformIO.Platform_SetClipboardTextFn(&g, text);
}
const char* ImGui::GetVersion()
@@ -10096,6 +10097,14 @@
if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && g.IO.BackendUsingLegacyKeyArrays == 1)
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
#endif
+
+ // Remap legacy clipboard handlers (OBSOLETED in 1.91.1, August 2024)
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ if (g.IO.GetClipboardTextFn != NULL && (g.PlatformIO.Platform_GetClipboardTextFn == NULL || g.PlatformIO.Platform_GetClipboardTextFn == Platform_GetClipboardTextFn_DefaultImpl))
+ g.PlatformIO.Platform_GetClipboardTextFn = [](ImGuiContext* ctx) { return ctx->IO.GetClipboardTextFn(ctx->IO.ClipboardUserData); };
+ if (g.IO.SetClipboardTextFn != NULL && (g.PlatformIO.Platform_SetClipboardTextFn == NULL || g.PlatformIO.Platform_SetClipboardTextFn == Platform_SetClipboardTextFn_DefaultImpl))
+ g.PlatformIO.Platform_SetClipboardTextFn = [](ImGuiContext* ctx, const char* text) { return ctx->IO.SetClipboardTextFn(ctx->IO.ClipboardUserData, text); };
+#endif
}
static void ImGui::ErrorCheckEndFrameSanityChecks()
@@ -14347,9 +14356,9 @@
// Win32 clipboard implementation
// We use g.ClipboardHandlerData for temporary storage to ensure it is freed on Shutdown()
-static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx)
+static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx)
{
- ImGuiContext& g = *(ImGuiContext*)user_data_ctx;
+ ImGuiContext& g = *ctx;
g.ClipboardHandlerData.clear();
if (!::OpenClipboard(NULL))
return NULL;
@@ -14370,7 +14379,7 @@
return g.ClipboardHandlerData.Data;
}
-static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
+static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext*, const char* text)
{
if (!::OpenClipboard(NULL))
return;
@@ -14397,7 +14406,7 @@
// OSX clipboard implementation
// If you enable this you will need to add '-framework ApplicationServices' to your linker command-line!
-static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
+static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext*, const char* text)
{
if (!main_clipboard)
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
@@ -14410,9 +14419,9 @@
}
}
-static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx)
+static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx)
{
- ImGuiContext& g = *(ImGuiContext*)user_data_ctx;
+ ImGuiContext& g = *ctx;
if (!main_clipboard)
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
PasteboardSynchronize(main_clipboard);
@@ -14446,15 +14455,15 @@
#else
// Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers.
-static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx)
+static const char* Platform_GetClipboardTextFn_DefaultImpl(ImGuiContext* ctx)
{
- ImGuiContext& g = *(ImGuiContext*)user_data_ctx;
+ ImGuiContext& g = *ctx;
return g.ClipboardHandlerData.empty() ? NULL : g.ClipboardHandlerData.begin();
}
-static void SetClipboardTextFn_DefaultImpl(void* user_data_ctx, const char* text)
+static void Platform_SetClipboardTextFn_DefaultImpl(ImGuiContext* ctx, const char* text)
{
- ImGuiContext& g = *(ImGuiContext*)user_data_ctx;
+ ImGuiContext& g = *ctx;
g.ClipboardHandlerData.clear();
const char* text_end = text + strlen(text);
g.ClipboardHandlerData.resize((int)(text_end - text) + 1);
diff --git a/imgui.h b/imgui.h
index a1ccfd7..2825cc6 100644
--- a/imgui.h
+++ b/imgui.h
@@ -2289,12 +2289,6 @@
void* BackendRendererUserData; // = NULL // User data for renderer backend
void* BackendLanguageUserData; // = NULL // User data for non C++ programming language backend
- // Optional: Access OS clipboard
- // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
- const char* (*GetClipboardTextFn)(void* user_data);
- void (*SetClipboardTextFn)(void* user_data, const char* text);
- void* ClipboardUserData;
-
//------------------------------------------------------------------
// Input - Call before calling NewFrame()
//------------------------------------------------------------------
@@ -2396,6 +2390,14 @@
//void* ImeWindowHandle; // [Obsoleted in 1.87] Set ImGuiViewport::PlatformHandleRaw instead. Set this to your HWND to get automatic IME cursor positioning.
#endif
+ // Legacy: before 1.91.1, clipboard functions were stored in ImGuiIO instead of ImGuiPlatformIO.
+ // As this is will affect all users of custom engines/backends, we are providing proper legacy redirection (will obsolete).
+#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
+ const char* (*GetClipboardTextFn)(void* user_data);
+ void (*SetClipboardTextFn)(void* user_data, const char* text);
+ void* ClipboardUserData;
+#endif
+
IMGUI_API ImGuiIO();
};
@@ -3483,6 +3485,12 @@
// Inputs - Interface with OS/backends
//------------------------------------------------------------------
+ // Optional: Access OS clipboard
+ // (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
+ const char* (*Platform_GetClipboardTextFn)(ImGuiContext* ctx);
+ void (*Platform_SetClipboardTextFn)(ImGuiContext* ctx, const char* text);
+ void* Platform_ClipboardUserData;
+
// Optional: Open link/folder/file in OS Shell
// (default to use ShellExecuteA() on Windows, system() on Linux/Mac)
bool (*Platform_OpenInShellFn)(ImGuiContext* ctx, const char* path);
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index f4625f2..2d96ed9 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -4740,7 +4740,7 @@
else if (is_cut || is_copy)
{
// Cut, Copy
- if (io.SetClipboardTextFn)
+ if (g.PlatformIO.Platform_SetClipboardTextFn != NULL)
{
const int ib = state->HasSelection() ? ImMin(state->Stb.select_start, state->Stb.select_end) : 0;
const int ie = state->HasSelection() ? ImMax(state->Stb.select_start, state->Stb.select_end) : state->CurLenW;