Skip to content

Commit cb56b0b

Browse files
committed
Removed leftover KeepAliveID() call in GetIDWithSeed() variant. (ocornut#5181) + doc tweaks.
1 parent e346059 commit cb56b0b

File tree

3 files changed

+51
-46
lines changed

3 files changed

+51
-46
lines changed

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ Breaking changes:
4343
automatically handling event capture. Examples that are using the OSX backend have removed
4444
all the now-unnecessary calls to ImGui_ImplOSX_HandleEvent(), applications can do as well.
4545
[@stuartcarnie] (#4821)
46+
- Internals: calling ButtonBehavior() without calling ItemAdd() now requires a KeepAliveID().
47+
This is because the KeepAliveID() call was moved from GetID() to ItemAdd()). (#5181)
4648

4749
Other Changes:
4850

docs/EXAMPLES.md

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,56 +17,60 @@ You can find Windows binaries for some of those example applications at:
1717

1818
Integration in a typical existing application, should take <20 lines when using standard backends.
1919

20-
At initialization:
21-
call ImGui::CreateContext()
22-
call ImGui_ImplXXXX_Init() for each backend.
20+
```cpp
21+
At initialization:
22+
call ImGui::CreateContext()
23+
call ImGui_ImplXXXX_Init() for each backend.
2324

24-
At the beginning of your frame:
25-
call ImGui_ImplXXXX_NewFrame() for each backend.
26-
call ImGui::NewFrame()
25+
At the beginning of your frame:
26+
call ImGui_ImplXXXX_NewFrame() for each backend.
27+
call ImGui::NewFrame()
2728

28-
At the end of your frame:
29-
call ImGui::Render()
30-
call ImGui_ImplXXXX_RenderDrawData() for your Renderer backend.
29+
At the end of your frame:
30+
call ImGui::Render()
31+
call ImGui_ImplXXXX_RenderDrawData() for your Renderer backend.
3132

32-
At shutdown:
33-
call ImGui_ImplXXXX_Shutdown() for each backend.
34-
call ImGui::DestroyContext()
33+
At shutdown:
34+
call ImGui_ImplXXXX_Shutdown() for each backend.
35+
call ImGui::DestroyContext()
36+
```
3537

3638
Example (using [backends/imgui_impl_win32.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp) + [backends/imgui_impl_dx11.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp)):
3739

38-
// Create a Dear ImGui context, setup some options
39-
ImGui::CreateContext();
40-
ImGuiIO& io = ImGui::GetIO();
41-
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable some options
42-
43-
// Initialize Platform + Renderer backends (here: using imgui_impl_win32.cpp + imgui_impl_dx11.cpp)
44-
ImGui_ImplWin32_Init(my_hwnd);
45-
ImGui_ImplDX11_Init(my_d3d_device, my_d3d_device_context);
46-
47-
// Application main loop
48-
while (true)
49-
{
50-
// Beginning of frame: update Renderer + Platform backend, start Dear ImGui frame
51-
ImGui_ImplDX11_NewFrame();
52-
ImGui_ImplWin32_NewFrame();
53-
ImGui::NewFrame();
54-
55-
// Any application code here
56-
ImGui::Text("Hello, world!");
57-
58-
// End of frame: render Dear ImGui
59-
ImGui::Render();
60-
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
61-
62-
// Swap
63-
g_pSwapChain->Present(1, 0);
64-
}
65-
66-
// Shutdown
67-
ImGui_ImplDX11_Shutdown();
68-
ImGui_ImplWin32_Shutdown();
69-
ImGui::DestroyContext();
40+
```cpp
41+
// Create a Dear ImGui context, setup some options
42+
ImGui::CreateContext();
43+
ImGuiIO& io = ImGui::GetIO();
44+
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable some options
45+
46+
// Initialize Platform + Renderer backends (here: using imgui_impl_win32.cpp + imgui_impl_dx11.cpp)
47+
ImGui_ImplWin32_Init(my_hwnd);
48+
ImGui_ImplDX11_Init(my_d3d_device, my_d3d_device_context);
49+
50+
// Application main loop
51+
while (true)
52+
{
53+
// Beginning of frame: update Renderer + Platform backend, start Dear ImGui frame
54+
ImGui_ImplDX11_NewFrame();
55+
ImGui_ImplWin32_NewFrame();
56+
ImGui::NewFrame();
57+
58+
// Any application code here
59+
ImGui::Text("Hello, world!");
60+
61+
// End of frame: render Dear ImGui
62+
ImGui::Render();
63+
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
64+
65+
// Swap
66+
g_pSwapChain->Present(1, 0);
67+
}
68+
69+
// Shutdown
70+
ImGui_ImplDX11_Shutdown();
71+
ImGui_ImplWin32_Shutdown();
72+
ImGui::DestroyContext();
73+
```
7074
7175
Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
7276
Please read the comments and instruction at the top of each file.

imgui.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ CODE
400400
- 2022/01/10 (1.87) - inputs: reworked keyboard IO. Removed io.KeyMap[], io.KeysDown[] in favor of calling io.AddKeyEvent(). Removed GetKeyIndex(), now unecessary. All IsKeyXXX() functions now take ImGuiKey values. All features are still functional until IMGUI_DISABLE_OBSOLETE_KEYIO is defined. Read Changelog and Release Notes for details.
401401
- IsKeyPressed(MY_NATIVE_KEY_XXX) -> use IsKeyPressed(ImGuiKey_XXX)
402402
- IsKeyPressed(GetKeyIndex(ImGuiKey_XXX)) -> use IsKeyPressed(ImGuiKey_XXX)
403-
- Backend writing to io.KeyMap[],io.KeysDown[] -> backend should call io.AddKeyEvent()
403+
- Backend writing to io.KeyMap[],io.KeysDown[] -> backend should call io.AddKeyEvent() (+ call io.SetKeyEventNativeData() if you want legacy user code to stil function with legacy key codes).
404404
- Backend writing to io.KeyCtrl, io.KeyShift.. -> backend should call io.AddKeyEvent() with ImGuiKey_ModXXX values. *IF YOU PULLED CODE BETWEEN 2021/01/10 and 2021/01/27: We used to have a io.AddKeyModsEvent() function which was now replaced by io.AddKeyEvent() with ImGuiKey_ModXXX values.*
405405
- one case won't work with backward compatibility: if your custom backend used ImGuiKey as mock native indices (e.g. "io.KeyMap[ImGuiKey_A] = ImGuiKey_A") because those values are now larger than the legacy KeyDown[] array. Will assert.
406406
- inputs: added ImGuiKey_ModCtrl/ImGuiKey_ModShift/ImGuiKey_ModAlt/ImGuiKey_ModSuper values to submit keyboard modifiers using io.AddKeyEvent(), instead of writing directly to io.KeyCtrl, io.KeyShift, io.KeyAlt, io.KeySuper.
@@ -7439,7 +7439,6 @@ void ImGui::PushOverrideID(ImGuiID id)
74397439
ImGuiID ImGui::GetIDWithSeed(const char* str, const char* str_end, ImGuiID seed)
74407440
{
74417441
ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
7442-
KeepAliveID(id);
74437442
ImGuiContext& g = *GImGui;
74447443
if (g.DebugHookIdInfo == id)
74457444
DebugHookIdInfo(id, ImGuiDataType_String, str, str_end);

0 commit comments

Comments
 (0)