mirror of
https://github.com/ocornut/imgui.git
synced 2026-09-27 00:13:29 +03:00
expose translate button and key functions as public
This commit is contained in:
parent
e69fd222c2
commit
7ba43170f8
2 changed files with 7 additions and 7 deletions
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// CHANGELOG
|
||||
// (minor and older changes stripped away, please see git history for details)
|
||||
// 2026-09-06: Inputs: Exposed mouse button and key translation functions as public.
|
||||
// 2026-09-06: DPI: Added ImGui_ImplEmscripten_GetCssToImGuiScale() getter.
|
||||
// 2026-09-05: DPI: Use the canvas framebuffer dimensions for display sizing and exact per-axis mouse coordinate scaling.
|
||||
// 2026-09-04: Replaced TargetDevicePixelRatio global with an Init() parameter and runtime setter.
|
||||
|
|
@ -28,11 +29,6 @@
|
|||
|
||||
extern ImGuiID ImHashStr(char const* data, size_t data_size = 0, ImGuiID seed = 0); // Declared in imgui_internal.h.
|
||||
|
||||
// W3C UI Events KeyboardEvent.code translation helpers
|
||||
|
||||
static ImGuiKey ImGui_ImplEmscripten_TranslateKey(char const* emscripten_key);
|
||||
static constexpr ImGuiMouseButton ImGui_ImplEmscripten_TranslateMouseButton(unsigned short emscripten_button) __attribute__((__const__));
|
||||
|
||||
// Browser cursor helpers, adapted from https://github.com/Armchair-Software/emscripten-browser-cursor
|
||||
|
||||
enum ImGui_ImplEmscripten_Cursor
|
||||
|
|
@ -606,7 +602,7 @@ static void ImGui_ImplEmscripten_SetBrowserCursor(char const* new_cursor)
|
|||
}, new_cursor);
|
||||
}
|
||||
|
||||
static constexpr ImGuiMouseButton ImGui_ImplEmscripten_TranslateMouseButton(unsigned short emscripten_button)
|
||||
ImGuiMouseButton ImGui_ImplEmscripten_TranslateMouseButton(unsigned short emscripten_button)
|
||||
{
|
||||
// Translate an emscripten-provided integer describing a mouse button to an imgui mouse button
|
||||
if (emscripten_button == 1) return ImGuiMouseButton_Middle; // 1 = middle mouse button
|
||||
|
|
@ -841,7 +837,7 @@ static ImGuiStorage const& ImGui_ImplEmscripten_GetKeyTranslationStorage()
|
|||
return storage;
|
||||
}
|
||||
|
||||
static ImGuiKey ImGui_ImplEmscripten_TranslateKey(char const* emscripten_key)
|
||||
ImGuiKey ImGui_ImplEmscripten_TranslateKey(const char* emscripten_key)
|
||||
{
|
||||
// Translate a W3C KeyboardEvent.code string into an ImGuiKey.
|
||||
if (emscripten_key == nullptr || emscripten_key[0] == '\0') return ImGuiKey_None;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ IMGUI_IMPL_API void ImGui_ImplEmscripten_SetTargetDevicePixelRatio(float target_
|
|||
// Return the scale used to convert browser CSS pixel coordinates to Dear ImGui coordinates. Valid after Init().
|
||||
IMGUI_IMPL_API ImVec2 ImGui_ImplEmscripten_GetCssToImGuiScale();
|
||||
|
||||
// Input translation helpers.
|
||||
IMGUI_IMPL_API ImGuiMouseButton ImGui_ImplEmscripten_TranslateMouseButton(unsigned short emscripten_button);
|
||||
IMGUI_IMPL_API ImGuiKey ImGui_ImplEmscripten_TranslateKey(const char* emscripten_key);
|
||||
|
||||
// Shut down the Emscripten backend. This unsets all Emscripten input callbacks set by Init.
|
||||
// Note it'll also unset any Emscripten input callbacks set elsewhere in the program!
|
||||
// Note also there is no obligation to ever call this, unless you intend to reset the backend (i.e. with ImGui::DestroyContext()).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue