Skip to content

Internal: Fix: Read back hexadecimal format properly in slider behavi… #3133

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

Closed

Conversation

LaMarche05
Copy link

If used with an hexadecimal format, ImGui::Slider* functions would break when coming across values including letters.

E.g.

static int n = 0;`
ImGui::SliderInt("foobar", &n, 0, 0x20, "0x%02X");

slider_issue

It is caused by ImAtoi() which assumes the given string is a decimal number. So instead we use scanf() by feeding it back the given format (and in case it fails we fallback to the previous method).

@ocornut ocornut added the bug label Apr 18, 2020
@ocornut ocornut force-pushed the master branch 2 times, most recently from 0c1e5bd to bb6a60b Compare August 27, 2021 19:10
@ocornut ocornut force-pushed the master branch 2 times, most recently from 8b83e0a to d735066 Compare December 13, 2021 11:31
@ocornut ocornut force-pushed the master branch 2 times, most recently from b3b85d8 to 0755767 Compare January 17, 2022 14:21
@ocornut ocornut force-pushed the master branch 3 times, most recently from c817acb to 8d39063 Compare February 15, 2022 16:25
ocornut added a commit that referenced this pull request Apr 4, 2022
…y much never worked). (#5165, #3133)

Ditched unnecessary code. When transitioning from float in 3e80874 we added an unnecessary path there, which evolved in c5fb929.
@ocornut
Copy link
Owner

ocornut commented Apr 4, 2022

See #5165 (had simpler fix, and either way both fixes are incomplete right now as ctrl+clicking input is broken)

@ocornut ocornut closed this Apr 4, 2022
ocornut added a commit that referenced this pull request Apr 4, 2022
…mat string. (#5165, #3133)

InputScalar: Fixed manual input when using %03d style width in display format string.
ocornut added a commit that referenced this pull request Apr 4, 2022
…mat string. (#5165, #3133)

InputScalar: Fixed manual input when using %03d style width in display format string.
(amended once)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants