mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-29 07:54:40 +00:00
ImGui::IsWindowAppearing detect window opening vs tabbing #9542
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#9542
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
Version 1.93.0, Branch: docking
Back-ends:
imgui_impl_win32.cpp + imgui_impl_dx11.cpp
Compiler, OS:
Windows 10 + MSVC 2026
Full config/build information:
Details:
Apologies for a bit of a lazy bug-report/question.
I was wondering if there is a way to detect if window is appearing from a closed state vs just becoming active (from inactive tab) ?
I have mostly relied on
ImGui::IsWindowAppearingfor setting focus on widgets and doing heavy per window init work (like refreshing data for list views), but I am noticing when tabbing it triggers that logic too.I can see that it makes sense (window is appearing), but is there a way to differentiate b/w opening vs getting activated?
I looked around a bit and found this issue which looks relevant (https://github.com/ocornut/imgui/issues/4177) but I am not sure if that answers my question.
I can solve this issue by manual bookeeping but wanted to check if theres any better/existing solution.
Screenshots/Video:
Minimal, Complete and Verifiable Example code:
Why would you need to use that information for?
What's the actual context?
What about a docked window that's been in an unselected tab since application boot (never selected) when would it be marked as "opening" in your logic? If marked as "opening" from initial frame but not active, then widgets are supposedly not submitted and that
SetKeyboardFocusHere()would never perform anything.Why would you need to use that information for?
What's the actual context?
What about a docked window that's been in an unselected tab since application boot (never selected) when would it be marked as "opening" in your logic? If marked as "opening" from initial frame but not active, then widgets are supposedly not submitted and that
SetKeyboardFocusHere()would never perform anything.Why would you need to use that information for?
What's the actual context?
What about a docked window that's been in an unselected tab since application boot (never selected) when would it be marked as "opening" in your logic? If marked as "opening" from initial frame but not active, then widgets are supposedly not submitted and that
SetKeyboardFocusHere()would never perform anything.Yeah, I think what you are saying makes sense. I feel like maybe I should refactor my setup.
For that particular code snippet should I use the
p_openflag paseed toImGui::Beginfor updating keyboard focus (everytime the window opens)?ImGui::IsWindowAppearing()+ImGui::SetKeyboardFocusHere()is probably more suited for popup style windows?Please feel free to close this as not an issue.
Yeah, I think what you are saying makes sense. I feel like maybe I should refactor my setup.
For that particular code snippet should I use the
p_openflag paseed toImGui::Beginfor updating keyboard focus (everytime the window opens)?ImGui::IsWindowAppearing()+ImGui::SetKeyboardFocusHere()is probably more suited for popup style windows?Please feel free to close this as not an issue.
Yeah, I think what you are saying makes sense. I feel like maybe I should refactor my setup.
For that particular code snippet should I use the
p_openflag paseed toImGui::Beginfor updating keyboard focus (everytime the window opens)?ImGui::IsWindowAppearing()+ImGui::SetKeyboardFocusHere()is probably more suited for popup style windows?Please feel free to close this as not an issue.
You haven’t answered the primary question so it’s difficult to give you the right answer.
Begin() can by definition never set *p_open = true it is generally set by your app in order to trigger the control flow that will call Begin().
You haven’t answered the primary question so it’s difficult to give you the right answer.
Begin() can by definition never set *p_open = true it is generally set by your app in order to trigger the control flow that will call Begin().
So I have a menu bar setup like this. The "open" state of the window is only known to the menu bar container, the callback itself doesn't have any knowledge of what state the window is getting drawn from (if its opened this frame, or just activated)
The callbacks use
ImGui::WindowAppearingfor resetting the state (not all widgets do this). The intention being that these widgets are stateless and once closed we no longer care about their state and it gets reset for next use.So I have a menu bar setup like this. The "open" state of the window is only known to the menu bar container, the callback itself doesn't have any knowledge of what state the window is getting drawn from (if its opened this frame, or just activated)
The callbacks use
ImGui::WindowAppearingfor resetting the state (not all widgets do this). The intention being that these widgets are stateless and once closed we no longer care about their state and it gets reset for next use.In your specific case you could in theory attempt to pass a reset signal to your tools.
Differentiating both cases is an interesting topic. If I grep for
Appearingit's used for a few other things and particularly default scrolling behavior for focus functions.It seems like there are related issues #4177, #2283 open.
Ref this was added in
91704b77with amends inf03ab2a5c.Will need to investigate further.
In your specific case you could in theory attempt to pass a reset signal to your tools.
Differentiating both cases is an interesting topic. If I grep for
Appearingit's used for a few other things and particularly default scrolling behavior for focus functions.It seems like there are related issues #4177, #2283 open.
Ref this was added in
91704b77with amends inf03ab2a5c.Will need to investigate further.
I think I will probably have to add a "WindowClosed" callback to handle the cleanup.
Thanks for the help!
Feel free to the mark the issue resolved/closed
I think I will probably have to add a "WindowClosed" callback to handle the cleanup.
Thanks for the help!
Feel free to the mark the issue resolved/closed
A callback or stored state/signal on your end would work.
A undocumented alternative would be, e.g.