mirror of
https://github.com/ocornut/imgui.git
synced 2025-01-31 03:53:44 +01:00
IO: amend PlatformOpenInShellFn specs to return a bool. (#7660)
Amend 8f36798
This commit is contained in:
parent
380b3559c6
commit
0ebf49b4c1
@ -579,7 +579,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
||||
io.ClipboardUserData = bd->Window;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
io.PlatformOpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplGlfw_EmscriptenOpenURL(url); };
|
||||
io.PlatformOpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplGlfw_EmscriptenOpenURL(url); return true; };
|
||||
#endif
|
||||
|
||||
// Create mouse cursors
|
||||
|
@ -441,7 +441,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
||||
io.ClipboardUserData = nullptr;
|
||||
io.PlatformSetImeDataFn = ImGui_ImplSDL2_PlatformSetImeData;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
io.PlatformOpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplSDL2_EmscriptenOpenURL(url); };
|
||||
io.PlatformOpenInShellFn = [](ImGuiContext*, const char* url) { ImGui_ImplSDL2_EmscriptenOpenURL(url); return true; };
|
||||
#endif
|
||||
|
||||
// Gamepad handling
|
||||
|
12
imgui.cpp
12
imgui.cpp
@ -1131,7 +1131,7 @@ static void WindowSettingsHandler_WriteAll(ImGuiContext*, ImGuiSetti
|
||||
static const char* GetClipboardTextFn_DefaultImpl(void* user_data_ctx);
|
||||
static void SetClipboardTextFn_DefaultImpl(void* user_data_ctx, const char* text);
|
||||
static void PlatformSetImeDataFn_DefaultImpl(ImGuiContext* ctx, ImGuiViewport* viewport, ImGuiPlatformImeData* data);
|
||||
static void PlatformOpenInShellFn_DefaultImpl(ImGuiContext* ctx, const char* path);
|
||||
static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext* ctx, const char* path);
|
||||
|
||||
namespace ImGui
|
||||
{
|
||||
@ -14358,12 +14358,12 @@ static void SetClipboardTextFn_DefaultImpl(void* user_data_ctx, const char* text
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "shell32")
|
||||
#endif
|
||||
static void PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
|
||||
static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
|
||||
{
|
||||
::ShellExecuteA(NULL, "open", path, NULL, NULL, SW_SHOWDEFAULT);
|
||||
return (INT_PTR)::ShellExecuteA(NULL, "open", path, NULL, NULL, SW_SHOWDEFAULT) > 32;
|
||||
}
|
||||
#elif !defined(IMGUI_DISABLE_DEFAULT_SHELL_FUNCTIONS)
|
||||
static void PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
|
||||
static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
|
||||
{
|
||||
#if __APPLE__
|
||||
const char* open_executable = "open";
|
||||
@ -14372,10 +14372,10 @@ static void PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char* path)
|
||||
#endif
|
||||
ImGuiTextBuffer buf;
|
||||
buf.appendf("%s \"%s\"", open_executable, path);
|
||||
system(buf.c_str());
|
||||
return system(buf.c_str()) != -1;
|
||||
}
|
||||
#else
|
||||
static void PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char*) {}
|
||||
static bool PlatformOpenInShellFn_DefaultImpl(ImGuiContext*, const char*) { return false; }
|
||||
#endif // Default shell handlers
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
4
imgui.h
4
imgui.h
@ -28,7 +28,7 @@
|
||||
// Library Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||
#define IMGUI_VERSION "1.91.0 WIP"
|
||||
#define IMGUI_VERSION_NUM 19092
|
||||
#define IMGUI_VERSION_NUM 19093
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
/*
|
||||
@ -2245,7 +2245,7 @@ struct ImGuiIO
|
||||
|
||||
// Optional: Open link/folder/file in OS Shell
|
||||
// (default to use ShellExecuteA() on Windows, system() on Linux/Mac)
|
||||
void (*PlatformOpenInShellFn)(ImGuiContext* ctx, const char* path);
|
||||
bool (*PlatformOpenInShellFn)(ImGuiContext* ctx, const char* path);
|
||||
void* PlatformOpenInShellUserData;
|
||||
|
||||
// Optional: Notify OS Input Method Editor of the screen position of your cursor for text input position (e.g. when using Japanese/Chinese IME on Windows)
|
||||
|
Loading…
x
Reference in New Issue
Block a user