Skip to content
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

Center input value in InputFloat as in DragFloat widget #3853

Open
dgregorius opened this issue Feb 28, 2021 · 2 comments
Open

Center input value in InputFloat as in DragFloat widget #3853

dgregorius opened this issue Feb 28, 2021 · 2 comments

Comments

@dgregorius
Copy link

Version/Branch of Dear ImGui:

Version: 1.82 WIP
Branch: Docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Compiler: VS 2019
Operating System: Windows 10

My Issue/Question:

ImGui::DragFloat centers the input value when not editing it. On the other hand ImGui::InputFloat aligns to the left. Is there a simple way to center the value in ImGui::InputFloat as for ImGui::DragFloat?

Thanks!

@rokups
Copy link
Contributor

rokups commented Mar 1, 2021

InputFloat() is using InputText() for rendering and there is no easy way to center text unfortunately.

@ocornut
Copy link
Owner

ocornut commented Mar 2, 2021

As specified in the question I think desired intent is to center (or right-align) value contents when NOT editing.

However as the relative mouse position at the time of activating an InputText() matters for selecting text, I don't think there's a 1 to 1 mapping with that Drag/Slider does, and the PR in #1442 is not a sufficient solution, but I presume we could work out a way to perform the alignment as least for single-line text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants