-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Regain focus on canvas after dialog/popup closes #741
Comments
Hello, Let me know if it does, otherwise please post a small repro or just the functions/flags you are using to get to this situation. How are you testing whether you apply the mouse wheel for zooming your canvas? |
Here's the part that handles the scroll wheel -> zooming. You'll notice at the bottom that I've put in a debug dump fprintf(stderr,"x"); that just lets me know when the main canvas is focused or not, and that appears to be the crucial aspect - when the x's appear there's no scroll activity, and vice-versa. This also happens immediately when the program is first loaded.
|
Does it still happen with the fix just posted above? |
PS: for |
I'm thinking that maybe I haven't been able to pull the latest from the repo, unfortunately my git-fu is weak; best I can report is this -
... which makes me think it's not actually using your latest updates ( and when I check the imgui.cpp code it doesn't even come close to matching, so I think I'll go sort that out first. Apologies for wasting your time. |
Git is a mystery to everyone it seems.. Yeah it looks like you are running an old version, and that fix is literally the last commit in the repo that I pushed this morning. |
I'll check with a couple of the other participants as a couple of them are more imbued with git-fu than I am. I suspect the detached HEAD option might be something to do with avoiding a moving API target. I'll report back later as soon as I have an answer. Thankyou. |
Managed to update the submodule. WorkstationTT:~/development/OpenBoardView$ git submodule Recompiled, still the same behaviour, so I'm thinking there's a bug in my code. I'll do some more digging around and see what I find and again, I'll report back 👍 |
Thanks! Please build a simplified repro. There's possibly a bug in the code but it's hard to guess anything without seeing much of your code. |
I added a bit of debugging code in my program and found essentially what the crux of the issue is;
Which, when running, provides the following; (when not 'focused') surface =? status (when focused, and scroll zoom working) surface =? surface For what ever reason, when my program starts up, and when the menu is selected or a dialog used, the focused window becomes "status", and when I click on the draw surface, it finally goes back to 'surface'. So, I suppose my question is, how do I forcibly make ImGui give focus back to 'surface' when I close the popups or finish the menu handling? |
I think I found the problem, if I comment out my status bar code, things magically work nice again :)
|
So your Status bar window is taking the focus, but you still haven't provided a repro that shows all the related code, aka how is focus taken away from your surface in the first place (dialogs/menus), so it is hard to tell what's wrong. When possible also try to strip down your repro to the useful bits (aka remove the styling bits) and test it as a standalone piece of code. When a window appears the first time is automatically takes focus, so that's unnecessary:
And the fact that you are passing ``ImGuiWindowFlags_NoFocusOnAppearing` to that same window requests the exact contrary here. And conversely, the status bar will take focus on the first frame as well, unless you pass it the |
Once again @ocornut , many thanks for you time. I have restructured things in the program and changed from Sorry I couldn't really provide a repro, as I'm not yet fully up to speed with how this program has been written I can't be sure where all the various attributes are being set (until I start reading more, which is usually when I learn where the fault(s) are). |
I have a situation where my main canvas/app loses mouse-focus after I open a dialog or menu selection and then close it, requiring me to click the main canvas for it to apply again (only has to be a click-down, the return/up isn't required). I'm using the mouse wheel to zoom in/out on the content and that doesn't work until I first click the mouse somewhere on the main canvas.
The keyboard inputs still work.
Is there something I can do to set the focus back to the canvas after I've done the ImGui::CloseCurrentPopup(); call?
The text was updated successfully, but these errors were encountered: