Skip to content

Commit afbc9e5

Browse files
ocornutsergeyn
authored andcommitted
Backends, Examples: Add comments about using WndProc handler and WantCaptureXXX flags. (ocornut#5061)
+ update README.
1 parent 7184c4f commit afbc9e5

File tree

22 files changed

+60
-53
lines changed

22 files changed

+60
-53
lines changed

backends/imgui_impl_allegro5.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,8 @@ static void ImGui_ImplAllegro5_UpdateKeyModifiers()
456456
}
457457

458458
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
459-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
460-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
459+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
460+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
461461
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
462462
bool ImGui_ImplAllegro5_ProcessEvent(ALLEGRO_EVENT* ev)
463463
{

backends/imgui_impl_sdl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ static void ImGui_ImplSDL2_UpdateKeyModifiers(SDL_Keymod sdl_key_mods)
237237
}
238238

239239
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
240-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
241-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
240+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
241+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
242242
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
243243
// If you have multiple SDL events and some of them are not meant to be used by dear imgui, you may need to filter events based on their windowID field.
244244
bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)

backends/imgui_impl_win32.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,10 @@ static ImGuiKey ImGui_ImplWin32_VirtualKeyToImGuiKey(WPARAM wParam)
488488
#endif
489489

490490
// Win32 message handler (process Win32 mouse/keyboard inputs, etc.)
491-
// Call from your application's message handler.
491+
// Call from your application's message handler. Keep calling your message handler unless this function returns TRUE.
492492
// When implementing your own backend, you can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if Dear ImGui wants to use your inputs.
493-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
494-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
493+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
494+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
495495
// Generally you may always pass all inputs to Dear ImGui, and hide them from your application based on those two flags.
496496
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinates when dragging mouse outside of our window bounds.
497497
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.

backends/imgui_impl_win32.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame();
2222
// Win32 message handler your application need to call.
2323
// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on <windows.h> from this helper.
2424
// - You should COPY the line below into your .cpp code to forward declare the function and then you can call it.
25+
// - Call from your application's message handler. Keep calling your message handler unless this function returns TRUE.
26+
2527
#if 0
2628
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
2729
#endif

docs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ See [Sponsors](https://github.com/ocornut/imgui/wiki/Sponsors) page.
195195
Sponsors
196196
--------
197197

198-
Ongoing Dear ImGui development is currently financially supported by users and private sponsors:
198+
Ongoing Dear ImGui development is currently financially supported in 2021-2022 by users and private sponsors:
199199

200200
*Platinum-chocolate sponsors*
201201
- [Blizzard](https://careers.blizzard.com/en-us/openings/engineering/all/all/all/1)
@@ -204,12 +204,12 @@ Ongoing Dear ImGui development is currently financially supported by users and p
204204
- [Ubisoft](https://montreal.ubisoft.com/en/ubisoft-sponsors-user-interface-library-for-c-dear-imgui), [Supercell](https://supercell.com)
205205

206206
*Chocolate sponsors*
207-
- [Activision](https://careers.activision.com/c/programmingsoftware-engineering-jobs), [Adobe](https://www.adobe.com/products/medium.html), [Aras Pranckevičius](https://aras-p.info), [Arkane Studios](https://www.arkane-studios.com), [Epic](https://www.unrealengine.com/en-US/megagrants), [Google](https://github.com/google/filament), [Nvidia](https://developer.nvidia.com/nvidia-omniverse), [RAD Game Tools](http://www.radgametools.com/)
207+
- [Adobe](https://www.adobe.com/products/medium.html), [Aras Pranckevičius](https://aras-p.info), [Epic](https://www.unrealengine.com/en-US/megagrants), [G3Dvu]().
208208

209209
*Salty-caramel sponsors*
210-
- [Framefield](http://framefield.com), [Grinding Gear Games](https://www.grindinggear.com), [Kylotonn](https://www.kylotonn.com), [Next Level Games](https://www.nextlevelgames.com), [O-Net Communications (USA)](http://en.o-netcom.com)
210+
- [Kylotonn](https://www.kylotonn.com), [O-Net Communications (USA)](http://en.o-netcom.com), [Wonderland Engine](https://wonderlandengine.com/).
211211

212-
Please see [detailed list of Dear ImGui supporters](https://github.com/ocornut/imgui/wiki/Sponsors) for past sponsors.
212+
Please see [detailed list of Dear ImGui supporters](https://github.com/ocornut/imgui/wiki/Sponsors) for sponsors of past years.
213213
From November 2014 to December 2019, ongoing development has also been financially supported by its users on Patreon and through individual donations.
214214

215215
**THANK YOU to all past and present supporters for helping to keep this project alive and thriving!**

examples/example_allegro5/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ int main(int, char**)
6969
{
7070
// Poll and handle events (inputs, window resize, etc.)
7171
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
72-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
73-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
72+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
73+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
7474
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
7575
ALLEGRO_EVENT ev;
7676
while (al_get_next_event(queue, &ev))

examples/example_emscripten_opengl3/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ static void main_loop(void* arg)
111111

112112
// Poll and handle events (inputs, window resize, etc.)
113113
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
114-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
115-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
114+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
115+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
116116
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
117117
SDL_Event event;
118118
while (SDL_PollEvent(&event))

examples/example_glfw_metal/main.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ int main(int, char**)
8888
{
8989
// Poll and handle events (inputs, window resize, etc.)
9090
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
91-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
92-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
91+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
92+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
9393
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
9494
glfwPollEvents();
9595

examples/example_glfw_opengl2/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ int main(int, char**)
8080
{
8181
// Poll and handle events (inputs, window resize, etc.)
8282
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
83-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
84-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
83+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
84+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
8585
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
8686
glfwPollEvents();
8787

examples/example_glfw_opengl3/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ int main(int, char**)
101101
{
102102
// Poll and handle events (inputs, window resize, etc.)
103103
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
104-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
105-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
104+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
105+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
106106
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
107107
glfwPollEvents();
108108

examples/example_glfw_vulkan/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ int main(int, char**)
467467
{
468468
// Poll and handle events (inputs, window resize, etc.)
469469
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
470-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
471-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
470+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
471+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
472472
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
473473
glfwPollEvents();
474474

examples/example_glut_opengl2/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ void glut_display_func()
9494
}
9595

9696
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
97-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
98-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
97+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
98+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
9999
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
100100

101101
int main(int argc, char** argv)
@@ -125,6 +125,7 @@ int main(int argc, char** argv)
125125
//ImGui::StyleColorsClassic();
126126

127127
// Setup Platform/Renderer backends
128+
// FIXME: Consider reworking this example to install our own GLUT funcs + forward calls ImGui_ImplGLUT_XXX ones, instead of using ImGui_ImplGLUT_InstallFuncs().
128129
ImGui_ImplGLUT_Init();
129130
ImGui_ImplGLUT_InstallFuncs();
130131
ImGui_ImplOpenGL2_Init();

examples/example_sdl_directx11/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ int main(int, char**)
9191
{
9292
// Poll and handle events (inputs, window resize, etc.)
9393
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
94-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
95-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
94+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
95+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
9696
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
9797
SDL_Event event;
9898
while (SDL_PollEvent(&event))

examples/example_sdl_metal/main.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ int main(int, char**)
8888
{
8989
// Poll and handle events (inputs, window resize, etc.)
9090
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
91-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
92-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
91+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
92+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
9393
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
9494
SDL_Event event;
9595
while (SDL_PollEvent(&event))

examples/example_sdl_opengl2/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ int main(int, char**)
7979
{
8080
// Poll and handle events (inputs, window resize, etc.)
8181
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
82-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
83-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
82+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
83+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
8484
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
8585
SDL_Event event;
8686
while (SDL_PollEvent(&event))

examples/example_sdl_opengl3/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ int main(int, char**)
101101
{
102102
// Poll and handle events (inputs, window resize, etc.)
103103
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
104-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
105-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
104+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
105+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
106106
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
107107
SDL_Event event;
108108
while (SDL_PollEvent(&event))

examples/example_sdl_sdlrenderer/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ int main(int, char**)
8585
{
8686
// Poll and handle events (inputs, window resize, etc.)
8787
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
88-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
89-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
88+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
89+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
9090
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
9191
SDL_Event event;
9292
while (SDL_PollEvent(&event))

examples/example_sdl_vulkan/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@ int main(int, char**)
460460
{
461461
// Poll and handle events (inputs, window resize, etc.)
462462
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
463-
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
464-
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
463+
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data.
464+
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data.
465465
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
466466
SDL_Event event;
467467
while (SDL_PollEvent(&event))

0 commit comments

Comments
 (0)