-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Regression? IsItemDeactivatedAfterEdit on InputScalar step buttons doesn't happen on frame writing to backing data #8149
Comments
Thank you for reporting. I actually introduced that change exactly for those +/- buttons, because it felt not right that a single click would react on mouse-up while a held button would repeat. For a repeating button of that kind it feels right than the initial mouse-down alter the value and then holding the button for a longer time alters it further. How it affected the timing if setting ActiveId and breaking this I will investigate. Note that I'm frankly not even sure this use case for non-string value has ever been officially supported. |
It actually never correctly worked before: int tmp = 10;
if (ImGui::InputInt("tmp", &tmp))
IMGUI_DEBUG_LOG("%d - Edited\n", tmp);
if (ImGui::IsItemDeactivatedAfterEdit())
IMGUI_DEBUG_LOG("%d - DeactivatedAfterEdit\n", tmp); A single/fast click would work because initial edit was on deactivated frame: [00253] 11 - Edited
[00253] 11 - DeactivatedAfterEdit But a hold-to-repeat click could release on any frame: [01328] 11 - Edited
[01331] 11 - Edited
[01334] 11 - Edited
[01337] 11 - Edited
[01338] 10 - DeactivatedAfterEdit The new behavior is actually more consistent. As per the API definition the current behavior is not incorrect. (we partially/intently supported this idiom for direct |
I'd be interested if you can elaborate on that, while I investigate if it seems sane to add a workaround to support this. |
Thanks for your quick feedback. A basic use case is a spline curve controlled by some drag points. Standard is having 3 control points, but you can control this number. If you change it then I have to add an item in the std::vector holding the points. lets say: int vecSz = myVec.size();
ImGui::InputInt("Items", &vecSz);
if (ImGui::IsItemDeactivatedAfterEdit()) {
myVec.resize(vecSz);
...
} |
…putInt/InputFloat step buttons affected some mis-uses (#8149)
I poked a bit. I don't think there is a sane way to workaround this from the point of view of the library (other than relying on the previous repeat behavior). The previous behavior was accidental and as mentioned didn't work if you held the step buttons. The general paradigm of dear imgui is that you should carry the only source of truth. I have amend the Changelog 8be0723 to resurface this better. Note that you are free to use Button() and react on them. Here specifically using But if you change your code to: int vecSz = myVec.size();
if (ImGui::InputInt("Items", &vecSz))
myVec.resize(vecSz);
...
}
But I agree it's not ideal because you would ideally want immediate feedback on pressing +/- but delayed feedback when inputting a number... |
The hypothetical We did some simplification work on |
Yes, sure that i should hold the data, but in this case it would mean adding a variable per vector, which I find not very nice. For the moment I will patch my code with 1st or 2nd solution depending on the presence of hardware behind, and if some day you manage the flag it will be great! |
I think the best workaround may be to use |
Thanks, I patched my stuff, mainly using a step to Null (not equal to 0) to hide +/- buttons, and manually added them right after. It does not handle repeat, but this is ok for now. |
Version/Branch of Dear ImGui:
Version 1.95.5
Back-ends:
imgui_impl_Vulkan.cpp + imgui_impl_GLFW.cpp
Compiler, OS:
Windows 11, Visual Studio 2022
Full config/build information:
No response
Details:
My Issue/Question:
Hi,
I noted a regression from 1.91.4 using IsItemDeactivatedAfterEdit() on 'temporary' (I mean not static nor saved in global objects) values.
With 1.91.4 I used to get the new value after calling IsItemDeactivatedAfterEdit(), now I always get the value before user input.
I didn't find anything on the changelog about it, and believe I have no particular configuration regarding this.
Anyway just changing the version of DearImgui changes the behavior.
I provide a small example below, better than words.
(I use this trick with temporary objects to resize vectors.)
Hope this is clear enough.
Regards
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: