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

InputDouble disallows inf and nan input #7096

Closed
PeterJohnson opened this issue Dec 7, 2023 · 2 comments
Closed

InputDouble disallows inf and nan input #7096

PeterJohnson opened this issue Dec 7, 2023 · 2 comments

Comments

@PeterJohnson
Copy link

Version/Branch of Dear ImGui:

Version: 64b1e44
Branch: docking

My Issue/Question:

InputDouble() does not allow inf or nan be input, despite these being recognized by sscanf() (see https://en.cppreference.com/w/cpp/string/byte/strtof) and output by printf(). This means an infinity/NaN value can be displayed, but not set. This is caused by ImGuiInputTextFlags_CharsScientific not allowing these characters: https://github.com/ocornut/imgui/blob/d72e1563d4274e0f1a21973cf2d98563d579d377/imgui_widgets.cpp#L3985C9-L3987C27

A workaround is to use InputScalar() and not setting ImGuiInputTextFlags_CharsScientific.

Standalone, minimal, complete and verifiable example:

ImGui::Begin("Example Bug");
double v = std::numeric_limits<double>::infinity();
InputDouble("test", &v);
ImGui::End();
@ocornut
Copy link
Owner

ocornut commented Dec 7, 2023

Lately I have been wondering if the char filtering is a good idea at all. I wonder if we should just tend to disable filtering and perform the scan>store>display sequence naturally when Enter is pressed.

@ocornut
Copy link
Owner

ocornut commented Jan 3, 2024

I removed the filter and "nan"/"inf" etc. parse fine now, so this is solved :)

@ocornut ocornut closed this as completed Jan 3, 2024
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

2 participants