Skip to content

Commit acfc779

Browse files
committed
Rename io.AddKeyModEvent() -> io.AddKeyModsEvent() and updated backends accordingly. (ocornut#2625, ocornut#4858)
Amend 790132a (breaking) # Conflicts: # backends/imgui_impl_glfw.cpp # backends/imgui_impl_sdl.cpp # backends/imgui_impl_win32.cpp
1 parent 9ce0f35 commit acfc779

10 files changed

+18
-18
lines changed

backends/imgui_impl_allegro5.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// CHANGELOG
1919
// (minor and older changes stripped away, please see git history for details)
20-
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
20+
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
2121
// 2021-12-08: Renderer: Fixed mishandling of the the ImDrawCmd::IdxOffset field! This is an old bug but it never had an effect until some internal rendering changes in 1.86.
2222
// 2021-08-17: Calling io.AddFocusEvent() on ALLEGRO_EVENT_DISPLAY_SWITCH_OUT/ALLEGRO_EVENT_DISPLAY_SWITCH_IN events.
2323
// 2021-06-29: Reorganized backend to pull data from a single structure to facilitate usage with multiple-contexts (all g_XXXX access changed to bd->XXXX).
@@ -570,7 +570,7 @@ void ImGui_ImplAllegro5_NewFrame()
570570
((al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT)) ? ImGuiKeyModFlags_Shift : 0) |
571571
((al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR)) ? ImGuiKeyModFlags_Alt : 0) |
572572
((al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN)) ? ImGuiKeyModFlags_Super : 0);
573-
io.AddKeyModEvent(key_mods);
573+
io.AddKeyModsEvent(key_mods);
574574

575575
ImGui_ImplAllegro5_UpdateMouseCursor();
576576
}

backends/imgui_impl_android.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
// CHANGELOG
2121
// (minor and older changes stripped away, please see git history for details)
22-
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
22+
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
2323
// 2021-03-04: Initial version.
2424

2525
#include "imgui.h"
@@ -292,7 +292,7 @@ void ImGui_ImplAndroid_NewFrame()
292292
io.SetKeyEventNativeData(key_event.Key, key_event.NativeKeycode, key_event.NativeScancode); // To support legacy indexing (<1.87 user code)
293293
key_queue.second.pop();
294294
}
295-
io.AddKeyModEvent(g_KeyModFlags);
295+
io.AddKeyModsEvent(g_KeyModFlags);
296296

297297
// Setup display size (every frame to accommodate for window resizing)
298298
int32_t window_width = ANativeWindow_getWidth(g_Window);

backends/imgui_impl_glfw.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// CHANGELOG
2222
// (minor and older changes stripped away, please see git history for details)
2323
// 2021-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
24-
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
24+
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
2525
// 2022-01-05: Inputs: Converting GLFW untranslated keycodes back to translated keycodes (in the ImGui_ImplGlfw_KeyCallback() function) in order to match the behavior of every other backend, and facilitate the use of GLFW with lettered-shortcuts API.
2626
// 2021-08-17: *BREAKING CHANGE*: Now using glfwSetWindowFocusCallback() to calling io.AddFocusEvent(). If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() and forward it to the backend via ImGui_ImplGlfw_WindowFocusCallback().
2727
// 2021-07-29: *BREAKING CHANGE*: Now using glfwSetCursorEnterCallback(). MousePos is correctly reported when the host platform window is hovered but not focused. If you called ImGui_ImplGlfw_InitXXX() with install_callbacks = false, you MUST install glfwSetWindowFocusCallback() callback and forward it to the backend via ImGui_ImplGlfw_CursorEnterCallback().
@@ -676,7 +676,7 @@ static void ImGui_ImplGlfw_UpdateKeyModifiers()
676676
(((glfwGetKey(bd->Window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS)) ? ImGuiKeyModFlags_Shift : 0) |
677677
(((glfwGetKey(bd->Window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS)) ? ImGuiKeyModFlags_Alt : 0) |
678678
(((glfwGetKey(bd->Window, GLFW_KEY_LEFT_SUPER) == GLFW_PRESS) || (glfwGetKey(bd->Window, GLFW_KEY_RIGHT_SUPER) == GLFW_PRESS)) ? ImGuiKeyModFlags_Super : 0);
679-
io.AddKeyModEvent(key_mods);
679+
io.AddKeyModsEvent(key_mods);
680680
}
681681

682682
void ImGui_ImplGlfw_NewFrame()

backends/imgui_impl_glut.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// CHANGELOG
2222
// (minor and older changes stripped away, please see git history for details)
23-
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
23+
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
2424
// 2019-04-03: Misc: Renamed imgui_impl_freeglut.cpp/.h to imgui_impl_glut.cpp/.h.
2525
// 2019-03-25: Misc: Made io.DeltaTime always above zero.
2626
// 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window.
@@ -210,7 +210,7 @@ static void ImGui_ImplGLUT_UpdateKeyboardMods()
210210
((glut_key_mods & GLUT_ACTIVE_CTRL) ? ImGuiKeyModFlags_Ctrl : 0) |
211211
((glut_key_mods & GLUT_ACTIVE_SHIFT) ? ImGuiKeyModFlags_Shift : 0) |
212212
((glut_key_mods & GLUT_ACTIVE_ALT) ? ImGuiKeyModFlags_Alt : 0);
213-
io.AddKeyModEvent(key_mods);
213+
io.AddKeyModsEvent(key_mods);
214214
}
215215

216216
static void ImGui_ImplGLUT_AddKeyEvent(ImGuiKey key, bool down, int native_keycode)

backends/imgui_impl_osx.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
// CHANGELOG
2626
// (minor and older changes stripped away, please see git history for details)
27-
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
27+
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
2828
// 2021-12-13: *BREAKING CHANGE* Add NSView parameter to ImGui_ImplOSX_Init(). Generally fix keyboard support. Using kVK_* codes for keyboard keys.
2929
// 2021-12-13: Add game controller support.
3030
// 2021-09-21: Use mach_absolute_time as CFAbsoluteTimeGetCurrent can jump backwards.
@@ -498,7 +498,7 @@ static void ImGui_ImplOSX_UpdateGamepads()
498498
static void ImGui_ImplOSX_UpdateKeyModifiers()
499499
{
500500
ImGuiIO& io = ImGui::GetIO();
501-
io.AddKeyModEvent(g_KeyModifiers);
501+
io.AddKeyModsEvent(g_KeyModifiers);
502502
}
503503

504504
void ImGui_ImplOSX_NewFrame(NSView* view)

backends/imgui_impl_sdl.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// CHANGELOG
2222
// (minor and older changes stripped away, please see git history for details)
2323
// 2021-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
24-
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
24+
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
2525
// 2021-08-17: Calling io.AddFocusEvent() on SDL_WINDOWEVENT_FOCUS_GAINED/SDL_WINDOWEVENT_FOCUS_LOST.
2626
// 2021-07-29: Inputs: MousePos is correctly reported when the host platform window is hovered but not focused (using SDL_GetMouseFocus() + SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, requires SDL 2.0.5+)
2727
// 2021-06:29: *BREAKING CHANGE* Removed 'SDL_Window* window' parameter to ImGui_ImplSDL2_NewFrame() which was unnecessary.
@@ -599,7 +599,7 @@ static void ImGui_ImplSDL2_UpdateKeyModifiers()
599599
((sdl_key_mods & KMOD_SHIFT) ? ImGuiKeyModFlags_Shift : 0) |
600600
((sdl_key_mods & KMOD_ALT) ? ImGuiKeyModFlags_Alt : 0) |
601601
((sdl_key_mods & KMOD_GUI) ? ImGuiKeyModFlags_Super : 0);
602-
io.AddKeyModEvent(key_mods);
602+
io.AddKeyModsEvent(key_mods);
603603
}
604604

605605
void ImGui_ImplSDL2_NewFrame()

backends/imgui_impl_win32.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
3535
// CHANGELOG
3636
// (minor and older changes stripped away, please see git history for details)
3737
// 2021-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface.
38-
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
38+
// 2022-01-10: Inputs: calling new io.AddKeyEvent(), io.AddKeyModsEvent() + io.SetKeyEventNativeData() API (1.87+). Support for full ImGuiKey range.
3939
// 2021-12-16: Inputs: Fill VK_LCONTROL/VK_RCONTROL/VK_LSHIFT/VK_RSHIFT/VK_LMENU/VK_RMENU for completeness.
4040
// 2021-08-17: Calling io.AddFocusEvent() on WM_SETFOCUS/WM_KILLFOCUS messages.
4141
// 2021-08-02: Inputs: Fixed keyboard modifiers being reported when host window doesn't have focus.
@@ -251,7 +251,7 @@ static void ImGui_ImplWin32_UpdateKeyModifiers()
251251
((IsVkDown(VK_LSHIFT) || IsVkDown(VK_RSHIFT)) ? ImGuiKeyModFlags_Shift : 0) |
252252
((IsVkDown(VK_LMENU) || IsVkDown(VK_RMENU)) ? ImGuiKeyModFlags_Alt : 0) |
253253
((IsVkDown(VK_LWIN) || IsVkDown(VK_RWIN)) ? ImGuiKeyModFlags_Super : 0);
254-
io.AddKeyModEvent(key_mods);
254+
io.AddKeyModsEvent(key_mods);
255255
}
256256

257257
// This code supports multi-viewports (multiple OS Windows mapped into different Dear ImGui viewports)

docs/CHANGELOG.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Breaking Changes:
106106

107107
- Reworked IO keyboard input system. (#2625, #3724) [@thedmd, @ocornut]
108108
- Added io.AddKeyEvent() function, obsoleting writing directly to io.KeyMap[], io.KeysDown[] arrays.
109-
- Added io.AddKeyModEvent() function, obsoleting writing directly to io.KeyCtrl, io.KeyShift etc.
109+
- Added io.AddKeyModsEvent() function, obsoleting writing directly to io.KeyCtrl, io.KeyShift etc.
110110
- Added io.SetKeyEventNativeData() function (optional) to pass native and old legacy indices.
111111
- Added full range of key enums in ImGuiKey (e.g. ImGuiKey_F1).
112112
- Added GetKeyName() helper function.

imgui.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ CODE
398398
- IsKeyPressed(MY_NATIVE_KEY_XXX) -> use IsKeyPressed(ImGuiKey_XXX)
399399
- IsKeyPressed(GetKeyIndex(ImGuiKey_XXX)) -> use IsKeyPressed(ImGuiKey_XXX)
400400
- Backend writing to io.KeyMap[],io.KeysDown[] -> backend should call io.AddKeyEvent()
401-
- inputs: added io.AddKeyModEvent() instead of writing directly to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper.
401+
- inputs: added io.AddKeyModsEvent() instead of writing directly to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper.
402402
- 2022/01/05 (1.87) - inputs: renamed ImGuiKey_KeyPadEnter to ImGuiKey_KeypadEnter to align with new symbols. Kept redirection enum.
403403
- 2022/01/05 (1.87) - removed io.ImeSetInputScreenPosFn() in favor of more flexible io.SetPlatformImeDataFn(). Removed 'void* io.ImeWindowHandle' in favor of writing to 'void* ImGuiViewport::PlatformHandleRaw'.
404404
- 2022/01/01 (1.87) - commented out redirecting functions/enums names that were marked obsolete in 1.69, 1.70, 1.71, 1.72 (March-July 2019)
@@ -1318,7 +1318,7 @@ void ImGuiIO::SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native
13181318
#endif
13191319
}
13201320

1321-
void ImGuiIO::AddKeyModEvent(ImGuiKeyModFlags modifiers)
1321+
void ImGuiIO::AddKeyModsEvent(ImGuiKeyModFlags modifiers)
13221322
{
13231323
KeyMods = modifiers;
13241324
KeyCtrl = (modifiers & ImGuiKeyModFlags_Ctrl) != 0;

imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,7 @@ struct ImGuiIO
20982098

20992099
// Input Functions
21002100
IMGUI_API void AddKeyEvent(ImGuiKey key, bool down); // Queue a new key down/up event. Key should be "translated" (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
2101-
IMGUI_API void AddKeyModEvent(ImGuiKeyModFlags modifiers); // Queue a change of Ctrl/Shift/Alt/Super modifiers
2101+
IMGUI_API void AddKeyModsEvent(ImGuiKeyModFlags modifiers);// Queue a change of Ctrl/Shift/Alt/Super modifiers
21022102
IMGUI_API void AddFocusEvent(bool focused); // Queue an hosting application/platform windows gain or loss of focus
21032103
IMGUI_API void AddInputCharacter(unsigned int c); // Queue new character input
21042104
IMGUI_API void AddInputCharacterUTF16(ImWchar16 c); // Queue new character input from an UTF-16 character, it can be a surrogate

0 commit comments

Comments
 (0)