-
-
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
EnterReturnsTrue behavior for SliderFloat etc textbox #3338
Comments
Hello, I believe you don't want to be testing the Enter key, rather you can read The value shifting as you edit is another task (#701) which is yet undone, will do it eventually, but if you can manage with -Omar |
OK, I'll have a look at |
Yes, but I think it should work (and minor: very slightly faster) to first test the return value from
Maybe, but I prefer to act based on concrete needs and if |
I tried
This didn't seem to work—I tried gating the call on InputText, like: if (InputText(...) && IsItemDeactivatedAfterEdit())
{
// update the value
} but InputText doesn't return true on the same frame that IsItemDeactivatedAfterEdit does (i.e. InputText returns true as you're typing, then IsItemDeactivatedAfterEdit returns true when you hit enter or tab away, etc). Simply calling InputText and then testing IsItemDeactivatedAfterEdit works as expected though.
Maybe I'm misunderstanding something here, but if I am concerned with the behavior of the temporary text boxes created by sliders, there doesn't seem to be a way to implement the IsItemDeactivatedAfterEdit behavior for them unless I either modify ImGui source, or I make my own copy of several layers of the slider code (SliderFloat, SliderScalar, TempInputScalar). Both create some extra work when it comes time to update to a newer version of ImGui. I am opting to modify ImGui source for now, so I'm fine here, but it is something to consider as you think about new designs for the slider API. 🙂 |
Actually, I spoke too soon. The |
You are right, that was a mistake in my earlier comment.
This seems to work for me, at least it does when I test that value in the demo: |
Ah, you can use IsItemDeactivatedAfterEdit and it applies to both the slider and the textbox, but I wanted to apply it only to the textbox (I still want live updates as the slider is dragged). |
@Reedbeta I have the same issue. Have you found a workaround? |
Oh, I did: if (ImGui::DragFloat3(label.c_str(), v.data(), .1) &&
!ImGui::TempInputIsActive(ImGui::GetActiveID()))
// ... modify model ... |
Version/Branch of Dear ImGui:
Version: 1.76 WIP
Branch: master
It would be nifty if we had a way to enable
ImGuiInputTextFlags_EnterReturnsTrue
on the textbox used by SliderFloat and friends when you ctrl+click. I prefer EnterReturnsTrue on most of my text boxes to avoid the value shifting wildly as you type. Currently, I've modifiedImGui::TempInputScalar
to add this flag. Thanks!The text was updated successfully, but these errors were encountered: