-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clearing InputText focus when platform window loses focus? #6467
Comments
Typically we don't want to alter ImGui state when host applications lose focus. |
I have problems with expression, English is my weakness |
This can be done by calling case WM_KILLFOCUS:
if(!ImGui::FindViewportByPlatformHandle(GetForegroundWindow()))
ImGui::ClearActiveID();
break; |
I do understand some application may want that, but simultaneously I am 100% sure some users will not want this. e.g. being able to Alt-Tab between two apps is often desirable. So at minimum perhaps we shouldn't clear focus but simply have option to e.g. disable blinking. |
Another case where this is relevant: I am currently testing out overlaying an ImGui application on top of a Electron/Tauri application by manually setting the ImGui application as the child window of the Electron/Tauri application and having no decorations. I am also taking care of position and resize so that the rendered ImGui part feels like a part of the application. There are two different applications where only one of them can have the input focus. To get the focus to switch to the ImGui part, my current solution is adding this in the beginning of the frame: if(ImGui::IsMouseClicked(ImGuiMouseButton_Left))
{
glfwFocusWindow(window);
} Haven't tested it much but obviously it needs to handle all clicks and I'm sure there are edge cases where it might not work. Now, due to the behaviour of not letting go of the internal ImGui caret, the user experience is that even though I've clicked an input field in the Electron/Tauri application, I still see a blinking caret in the ImGui part, even though that application has lost input focus. Just felt like I could add another use case for when disabling the caret is useful. PS. |
Version: Dear ImGui 1.89.6 WIP (18958)
Branch: master
Back-ends: imgui_impl_win32 + imgui_impl_opengl3
My Issue/Question:
In the InputText focus state, after the Win32 window loses focus, InputText will remain in the input state
How to cancel an input state
The text was updated successfully, but these errors were encountered: