-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Push/PopID() for PopUps? #747
Comments
You can form a string with a unique identifier behind ## and use that. Awkward but works. BeginChild() has a overload taking ImGuiID but not BeginPopup(). Also there's currently quite some confusion with the childs id which I would like to sort out before making any hasty change such as adding the equivalent overload in BeginPopup(). Also see #331 |
…essly waking up the root "Debug" window) (#747)
@adcox I just came back to this and realized my answer wasn't really useful (as you already had figured out you could build up identifiers). Two things:
(But exposing those isn't as trivial as one would expect, because the popup code is reliant on the popup stack/order, and those underlying function always assume the ID is at the current popup stack level.) |
I'd like this to be resolved; maybe have FindWindowByName()/CreateNewWindow use the ID stack? Or use the pointer provided as an additional source for calculating the window ID |
@ocornut I'm no longer a developer on the project that was using imgui and it's been far too long... I can't make any intelligent comments on this issue anymore. Thanks for the additional feedback, though! |
I was going to create a new issue but just decided to bump this existing one since it was relevant to what I needed |
@Someguynamedpie Afaik the problem described by the original poster was fixed (see above). Could you describe your problem and use case? There's always a Debug window pushed in the stack and so you can always call GetID(). You can also use ImHash(). |
It's possible I misunderstood the original question; I call Begin() twice with both windows having the same name, so it thinks I'm trying to use the existing window when in reality I'm trying to create a new window with the same name. |
@Someguynamedpie: Calling Begin() twice with the same identifier appends to the window. |
I know about the ## operators, but I'd prefer not to do that for performance and extensibility reasons, hence why it'd be nice to have PushID work on them. |
Sorry that statement doesn't make much sense. The operator is available for exactly this use case and Begin identifiers don't use the id stack as it would introduces undesirable limitations to using imgui.
|
Because I'd need to sprintf every frame for every unique window and know ahead of time the max buffer size to house the pointer to the object (or a unique ID nonetheless); what kind limitations would the id stack impose on Begin if you don't mind me asking? |
The users needs to be able to create or append to a known window in every possible context.
(Dear imgui relies on sprintf everywhere, if declaring eg. a 128 char array on the stack and calling sprintf every frame is a problem for you perhaps it isn't the right library for you?)
|
If I didn't have any user generated content it wouldn't be a big issue because yeah I could just use a static buffer. |
Just include the hash of your content after the ### marker. |
Is there a way to specify a unique ID for a popup that isn't a child of a window, i.e., is not between
Begin()
andEnd()
? In my application, I have several instances of a class that creates a popup window when clicked. Since there are multiple instances, I need to specify a unique ID for each; I tried usingPushID(this)
andPopID
, but then a default window object is created... I can work around by creating a hidden window and then creating the popup "within" the hidden window, but I'm curious to know if there's another/better way uniquely identify widgets outside of windows.The text was updated successfully, but these errors were encountered: