Comments (3)
Before calling ImGui::Begin()
for your window, you can call ImGui::SetNextWindowFocus()
to bring it to the front and focus it. For tree nodes and collapsing headers you can use ImGui::SetNextItemOpen()
and ImGui::SetScrollHereY()
to scroll to the current cursor position.
from imgui.
It's not a trivial problem to solve in a generic manner here, as they are many variations of desired behavior and/or things are implemented.
(1) You ought to focus the window:
ImGui::SetWindowFocus("name")
(or ImGui::SetNextWindowFocus()
before Begin()
)
(2) As for the tree open-state itself, depending on how you store your focus request (as a path?), if you can compute their ImGuiID you might access the storage directly (ImGui::GetStateStorage()->SetBool()
, see #7553) so you might incrementally as you render the tree use data from your focus request path to call ImGui::SetNextItemOpen(true / false)
on tree nodes.
(3) And you want to see scrolling for which you can use ImGui::SetScrollHereY()
.
Other notes:
SetScrollHereXXX()
/SetKeyboardFocusHere()` are rather old APIs and for the later its parameter is inconsistent with most other API, but it generally works. The underlying functions have been quite reworked/improved but haven't made it to public API yet, but I expect things to evolve toward a generally saner set of ActivateItem()/ScrollToItem()/FocusItem() functions with a bunch of nice flags.- Test Engine has ways to do all of this in much more simple standardized way, but it's not designed for the same thing and would likely be weird/overkill to use for this situation.
from imgui.
Thank you folks! A combo of SetWindowFocus(name) and SetNextItemOpen seemed to work. Luckily my code is mostly autogenerated, so I only had to add it to two places to work everywhere. (SetNextWindowFocus didn't seem to work, maybe because I was attempting to focus the same frame that I was adding new windows)
from imgui.
Related Issues (20)
- imgui_widgets.cpp gives 200+ errors HOT 1
- How can I size a table correctly for a given number of rows when using ImGuiTableFlags_ScrollX? HOT 4
- Image Loading Not Working
- Item-tooltip for group will disappear for a short time if the widget inside is clicked HOT 1
- Multi-viewport: window constrained to main viewport moves if it goes outside of viewport HOT 2
- Add a flag to disable Ctrl+Tab navigation HOT 1
- Renderer backend for the new SDL3 GPU API HOT 6
- Advice on implementing a visual tour for a user interface HOT 5
- Merging icon font doesn't work HOT 7
- Not all expected cells are selected when drag-selecting in an x-scrolling table
- Late availability of monitor information HOT 2
- IMGUI_DISABLE_OBSOLETE_FUNCTIONS does more than hiding obsoleted functions HOT 6
- Translating between backend keycode and ImGuiKey HOT 1
- Lack of separate ImGuiDockNodeFlags_NoDockingSplitMe flag in 1.91 HOT 2
- Question - D3D12 Texture
- Scrollbar behavior change HOT 8
- IsItemDeactivatedAfterEdit and InputTextMultiline HOT 3
- Displaying a slice of a 3D texture HOT 1
- SDL2 backend does not build on UWP HOT 4
- Latest Dawn source code breaks WGPU Backend. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgui.