mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Added a void* user_data parameter to Clipboard function handlers. (#875)
This commit is contained in:
parent
d649bc485b
commit
0d3f8807c7
@ -1,6 +1,9 @@
|
|||||||
// ImGui Allegro 5 bindings
|
// ImGui Allegro 5 bindings
|
||||||
// In this binding, ImTextureID is used to store a 'ALLEGRO_BITMAP*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
// In this binding, ImTextureID is used to store a 'ALLEGRO_BITMAP*' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// - Clipboard is not supported.
|
||||||
|
|
||||||
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
|
||||||
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
|
||||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
// Providing a standalone iOS application with Synergy integration makes this sample more verbose than others. It also hasn't been tested as much.
|
// Providing a standalone iOS application with Synergy integration makes this sample more verbose than others. It also hasn't been tested as much.
|
||||||
// Refer to other examples to get an easier understanding of how to integrate ImGui into your existing application.
|
// Refer to other examples to get an easier understanding of how to integrate ImGui into your existing application.
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
// - Clipboard is not supported.
|
||||||
|
|
||||||
#import <OpenGLES/ES3/gl.h>
|
#import <OpenGLES/ES3/gl.h>
|
||||||
#import <OpenGLES/ES3/glext.h>
|
#import <OpenGLES/ES3/glext.h>
|
||||||
|
|
||||||
@ -288,7 +291,6 @@ void ImGui_ClipboardCallback(uSynergyCookie cookie, enum uSynergyClipboardFormat
|
|||||||
printf("Synergy: clipboard callback TODO\n" );
|
printf("Synergy: clipboard callback TODO\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@interface ImGuiHelper ()
|
@interface ImGuiHelper ()
|
||||||
{
|
{
|
||||||
BOOL _mouseDown;
|
BOOL _mouseDown;
|
||||||
|
@ -89,28 +89,24 @@ void ImGui_Marmalade_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
// TODO: restore modified state (i.e. mvp matrix)
|
// TODO: restore modified state (i.e. mvp matrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ImGui_Marmalade_GetClipboardText()
|
static const char* ImGui_Marmalade_GetClipboardText(void* /*user_data*/)
|
||||||
{
|
{
|
||||||
if (s3eClipboardAvailable())
|
if (!s3eClipboardAvailable())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (int size = s3eClipboardGetText(NULL, 0))
|
||||||
{
|
{
|
||||||
int size = s3eClipboardGetText(NULL, 0);
|
if (g_ClipboardText)
|
||||||
if (size > 0)
|
delete[] g_ClipboardText;
|
||||||
{
|
g_ClipboardText = new char[size];
|
||||||
if (g_ClipboardText)
|
g_ClipboardText[0] = '\0';
|
||||||
{
|
s3eClipboardGetText(g_ClipboardText, size);
|
||||||
delete[] g_ClipboardText;
|
|
||||||
g_ClipboardText = NULL;
|
|
||||||
}
|
|
||||||
g_ClipboardText = new char[size];
|
|
||||||
g_ClipboardText[0] = '\0';
|
|
||||||
s3eClipboardGetText(g_ClipboardText, size);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_ClipboardText;
|
return g_ClipboardText;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_Marmalade_SetClipboardText(const char* text)
|
static void ImGui_Marmalade_SetClipboardText(void* /*user_data*/, const char* text)
|
||||||
{
|
{
|
||||||
if (s3eClipboardAvailable())
|
if (s3eClipboardAvailable())
|
||||||
s3eClipboardSetText(text);
|
s3eClipboardSetText(text);
|
||||||
|
@ -112,14 +112,14 @@ void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ImGui_ImplGlfw_GetClipboardText()
|
static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
|
||||||
{
|
{
|
||||||
return glfwGetClipboardString(g_Window);
|
return glfwGetClipboardString((GLFWwindow*)user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGlfw_SetClipboardText(const char* text)
|
static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
|
||||||
{
|
{
|
||||||
glfwSetClipboardString(g_Window, text);
|
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
||||||
@ -219,6 +219,7 @@ bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
|||||||
io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||||
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
||||||
|
io.ClipboardUserData = g_Window;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
||||||
#endif
|
#endif
|
||||||
|
@ -129,14 +129,14 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ImGui_ImplGlfwGL3_GetClipboardText()
|
static const char* ImGui_ImplGlfwGL3_GetClipboardText(void* user_data)
|
||||||
{
|
{
|
||||||
return glfwGetClipboardString(g_Window);
|
return glfwGetClipboardString((GLFWwindow*)user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGlfwGL3_SetClipboardText(const char* text)
|
static void ImGui_ImplGlfwGL3_SetClipboardText(void* user_data, const char* text)
|
||||||
{
|
{
|
||||||
glfwSetClipboardString(g_Window, text);
|
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
||||||
@ -329,6 +329,7 @@ bool ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks)
|
|||||||
io.RenderDrawListsFn = ImGui_ImplGlfwGL3_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
io.RenderDrawListsFn = ImGui_ImplGlfwGL3_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||||
io.SetClipboardTextFn = ImGui_ImplGlfwGL3_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplGlfwGL3_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplGlfwGL3_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplGlfwGL3_GetClipboardText;
|
||||||
|
io.ClipboardUserData = g_Window;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
||||||
#endif
|
#endif
|
||||||
|
@ -101,12 +101,12 @@ void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ImGui_ImplSdl_GetClipboardText()
|
static const char* ImGui_ImplSdl_GetClipboardText(void*)
|
||||||
{
|
{
|
||||||
return SDL_GetClipboardText();
|
return SDL_GetClipboardText();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSdl_SetClipboardText(const char* text)
|
static void ImGui_ImplSdl_SetClipboardText(void*, const char* text)
|
||||||
{
|
{
|
||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
@ -214,6 +214,7 @@ bool ImGui_ImplSdl_Init(SDL_Window* window)
|
|||||||
io.RenderDrawListsFn = ImGui_ImplSdl_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
io.RenderDrawListsFn = ImGui_ImplSdl_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||||
io.SetClipboardTextFn = ImGui_ImplSdl_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplSdl_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplSdl_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplSdl_GetClipboardText;
|
||||||
|
io.ClipboardUserData = NULL;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SDL_SysWMinfo wmInfo;
|
SDL_SysWMinfo wmInfo;
|
||||||
|
@ -123,12 +123,12 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
glScissor(last_scissor_box[0], last_scissor_box[1], (GLsizei)last_scissor_box[2], (GLsizei)last_scissor_box[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ImGui_ImplSdlGL3_GetClipboardText()
|
static const char* ImGui_ImplSdlGL3_GetClipboardText(void*)
|
||||||
{
|
{
|
||||||
return SDL_GetClipboardText();
|
return SDL_GetClipboardText();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplSdlGL3_SetClipboardText(const char* text)
|
static void ImGui_ImplSdlGL3_SetClipboardText(void*, const char* text)
|
||||||
{
|
{
|
||||||
SDL_SetClipboardText(text);
|
SDL_SetClipboardText(text);
|
||||||
}
|
}
|
||||||
@ -327,6 +327,7 @@ bool ImGui_ImplSdlGL3_Init(SDL_Window* window)
|
|||||||
io.RenderDrawListsFn = ImGui_ImplSdlGL3_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
io.RenderDrawListsFn = ImGui_ImplSdlGL3_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||||
io.SetClipboardTextFn = ImGui_ImplSdlGL3_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplSdlGL3_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplSdlGL3_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplSdlGL3_GetClipboardText;
|
||||||
|
io.ClipboardUserData = NULL;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SDL_SysWMinfo wmInfo;
|
SDL_SysWMinfo wmInfo;
|
||||||
|
@ -401,14 +401,14 @@ void ImGui_ImplGlfwVulkan_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* ImGui_ImplGlfwVulkan_GetClipboardText()
|
static const char* ImGui_ImplGlfwVulkan_GetClipboardText(void* user_data)
|
||||||
{
|
{
|
||||||
return glfwGetClipboardString(g_Window);
|
return glfwGetClipboardString((GLFWwindow*)user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ImGui_ImplGlfwVulkan_SetClipboardText(const char* text)
|
static void ImGui_ImplGlfwVulkan_SetClipboardText(void* user_data, const char* text)
|
||||||
{
|
{
|
||||||
glfwSetClipboardString(g_Window, text);
|
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplGlfwVulkan_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
void ImGui_ImplGlfwVulkan_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
||||||
@ -861,6 +861,7 @@ bool ImGui_ImplGlfwVulkan_Init(GLFWwindow* window, bool install_callbacks, Im
|
|||||||
io.RenderDrawListsFn = ImGui_ImplGlfwVulkan_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
io.RenderDrawListsFn = ImGui_ImplGlfwVulkan_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||||
io.SetClipboardTextFn = ImGui_ImplGlfwVulkan_SetClipboardText;
|
io.SetClipboardTextFn = ImGui_ImplGlfwVulkan_SetClipboardText;
|
||||||
io.GetClipboardTextFn = ImGui_ImplGlfwVulkan_GetClipboardText;
|
io.GetClipboardTextFn = ImGui_ImplGlfwVulkan_GetClipboardText;
|
||||||
|
io.ClipboardUserData = g_Window;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
io.ImeWindowHandle = glfwGetWin32Window(g_Window);
|
||||||
#endif
|
#endif
|
||||||
|
25
imgui.cpp
25
imgui.cpp
@ -150,6 +150,7 @@
|
|||||||
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
Here is a change-log of API breaking changes, if you are using one of the functions listed, expect to have to fix some code.
|
||||||
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
Also read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||||
|
|
||||||
|
- 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it.
|
||||||
- 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
|
- 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
|
||||||
- 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
|
- 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
|
||||||
- 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore.
|
- 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore.
|
||||||
@ -703,8 +704,8 @@ static bool DataTypeApplyOpFromText(const char* buf, const char* ini
|
|||||||
// Platform dependent default implementations
|
// Platform dependent default implementations
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static const char* GetClipboardTextFn_DefaultImpl();
|
static const char* GetClipboardTextFn_DefaultImpl(void* user_data);
|
||||||
static void SetClipboardTextFn_DefaultImpl(const char* text);
|
static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text);
|
||||||
static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
|
static void ImeSetInputScreenPosFn_DefaultImpl(int x, int y);
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -829,6 +830,7 @@ ImGuiIO::ImGuiIO()
|
|||||||
MemFreeFn = free;
|
MemFreeFn = free;
|
||||||
GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
|
GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
|
||||||
SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
|
SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
|
||||||
|
ClipboardUserData = NULL;
|
||||||
ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl;
|
ImeSetInputScreenPosFn = ImeSetInputScreenPosFn_DefaultImpl;
|
||||||
|
|
||||||
// Set OS X style defaults based on __APPLE__ compile time flag
|
// Set OS X style defaults based on __APPLE__ compile time flag
|
||||||
@ -2010,13 +2012,13 @@ void ImGui::MemFree(void* ptr)
|
|||||||
|
|
||||||
const char* ImGui::GetClipboardText()
|
const char* ImGui::GetClipboardText()
|
||||||
{
|
{
|
||||||
return GImGui->IO.GetClipboardTextFn ? GImGui->IO.GetClipboardTextFn() : "";
|
return GImGui->IO.GetClipboardTextFn ? GImGui->IO.GetClipboardTextFn(GImGui->IO.ClipboardUserData) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::SetClipboardText(const char* text)
|
void ImGui::SetClipboardText(const char* text)
|
||||||
{
|
{
|
||||||
if (GImGui->IO.SetClipboardTextFn)
|
if (GImGui->IO.SetClipboardTextFn)
|
||||||
GImGui->IO.SetClipboardTextFn(text);
|
GImGui->IO.SetClipboardTextFn(GImGui->IO.ClipboardUserData, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ImGui::GetVersion()
|
const char* ImGui::GetVersion()
|
||||||
@ -5796,8 +5798,7 @@ void ImGui::LogFinish()
|
|||||||
}
|
}
|
||||||
if (g.LogClipboard->size() > 1)
|
if (g.LogClipboard->size() > 1)
|
||||||
{
|
{
|
||||||
if (g.IO.SetClipboardTextFn)
|
SetClipboardText(g.LogClipboard->begin());
|
||||||
g.IO.SetClipboardTextFn(g.LogClipboard->begin());
|
|
||||||
g.LogClipboard->clear();
|
g.LogClipboard->clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7859,7 +7860,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
const int ie = edit_state.HasSelection() ? ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end) : edit_state.CurLenW;
|
const int ie = edit_state.HasSelection() ? ImMax(edit_state.StbState.select_start, edit_state.StbState.select_end) : edit_state.CurLenW;
|
||||||
edit_state.TempTextBuffer.resize((ie-ib) * 4 + 1);
|
edit_state.TempTextBuffer.resize((ie-ib) * 4 + 1);
|
||||||
ImTextStrToUtf8(edit_state.TempTextBuffer.Data, edit_state.TempTextBuffer.Size, edit_state.Text.Data+ib, edit_state.Text.Data+ie);
|
ImTextStrToUtf8(edit_state.TempTextBuffer.Data, edit_state.TempTextBuffer.Size, edit_state.Text.Data+ib, edit_state.Text.Data+ie);
|
||||||
io.SetClipboardTextFn(edit_state.TempTextBuffer.Data);
|
SetClipboardText(edit_state.TempTextBuffer.Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cut)
|
if (cut)
|
||||||
@ -7871,7 +7872,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
|
|||||||
else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_V) && is_editable)
|
else if (is_shortcut_key_only && IsKeyPressedMap(ImGuiKey_V) && is_editable)
|
||||||
{
|
{
|
||||||
// Paste
|
// Paste
|
||||||
if (const char* clipboard = io.GetClipboardTextFn ? io.GetClipboardTextFn() : NULL)
|
if (const char* clipboard = GetClipboardText())
|
||||||
{
|
{
|
||||||
// Filter pasted buffer
|
// Filter pasted buffer
|
||||||
const int clipboard_len = (int)strlen(clipboard);
|
const int clipboard_len = (int)strlen(clipboard);
|
||||||
@ -9565,7 +9566,7 @@ void ImGui::ValueColor(const char* prefix, ImU32 v)
|
|||||||
#pragma comment(lib, "user32")
|
#pragma comment(lib, "user32")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char* GetClipboardTextFn_DefaultImpl()
|
static const char* GetClipboardTextFn_DefaultImpl(void*)
|
||||||
{
|
{
|
||||||
static ImVector<char> buf_local;
|
static ImVector<char> buf_local;
|
||||||
buf_local.clear();
|
buf_local.clear();
|
||||||
@ -9585,7 +9586,7 @@ static const char* GetClipboardTextFn_DefaultImpl()
|
|||||||
return buf_local.Data;
|
return buf_local.Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetClipboardTextFn_DefaultImpl(const char* text)
|
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
||||||
{
|
{
|
||||||
if (!OpenClipboard(NULL))
|
if (!OpenClipboard(NULL))
|
||||||
return;
|
return;
|
||||||
@ -9604,13 +9605,13 @@ static void SetClipboardTextFn_DefaultImpl(const char* text)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
|
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
|
||||||
static const char* GetClipboardTextFn_DefaultImpl()
|
static const char* GetClipboardTextFn_DefaultImpl(void*)
|
||||||
{
|
{
|
||||||
return GImGui->PrivateClipboard;
|
return GImGui->PrivateClipboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
|
// Local ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers
|
||||||
static void SetClipboardTextFn_DefaultImpl(const char* text)
|
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
if (g.PrivateClipboard)
|
if (g.PrivateClipboard)
|
||||||
|
5
imgui.h
5
imgui.h
@ -757,8 +757,9 @@ struct ImGuiIO
|
|||||||
|
|
||||||
// Optional: access OS clipboard
|
// 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)
|
// (default to use native Win32 clipboard on Windows, otherwise uses a private clipboard. Override to access OS clipboard on other architectures)
|
||||||
const char* (*GetClipboardTextFn)();
|
const char* (*GetClipboardTextFn)(void* user_data);
|
||||||
void (*SetClipboardTextFn)(const char* text);
|
void (*SetClipboardTextFn)(void* user_data, const char* text);
|
||||||
|
void* ClipboardUserData;
|
||||||
|
|
||||||
// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
|
// Optional: override memory allocations. MemFreeFn() may be called with a NULL pointer.
|
||||||
// (default to posix malloc/free)
|
// (default to posix malloc/free)
|
||||||
|
Loading…
Reference in New Issue
Block a user