InputScalar: fixed not parsing user input when the display format is configured not to show the scalar value. (#9385)
build / Build - Windows (push) Has been cancelled
build / Build - Linux (push) Has been cancelled
build / Build - MacOS (push) Has been cancelled
build / Build - iOS (push) Has been cancelled
build / Build - Emscripten (push) Has been cancelled
build / Build - Android (push) Has been cancelled
build / Test - Windows (push) Has been cancelled
build / Test - Linux (push) Has been cancelled

Useful e.g. for displaying "mixed" inputs, where a single field might represent multiple different values.
This commit is contained in:
Alexander "FireFox" Ong
2026-04-28 20:44:20 +10:00
committed by ocornut
parent dee9b15bbe
commit 865a6dfa59
2 changed files with 8 additions and 1 deletions
+2
View File
@@ -97,6 +97,8 @@ Other Changes:
with 1.91.4 behavior.
- In a majority of cases you should use IsItemDeactivatedAfterEdit() instead,
but it still has a few edge cases flaws (to be addressed soon).
- InputInt, InputFloat, InputScalar: allow passing a format string that does not display
the scalar value. Parsing input with default format for the type. (#9385) [@FireFox2000000]
- Multi-Select:
- Fixed an issue using Multi-Select within a Table causing column width measurement to
be invalid when trailing column contents is not submitted in the last row. (#9341, #8250)
+6 -1
View File
@@ -2375,12 +2375,17 @@ bool ImGui::DataTypeApplyFromText(const char* buf, ImGuiDataType data_type, void
// Sanitize format
// - For float/double we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in, so force them into %f and %lf
// - In theory could treat empty format as using default, but this would only cover rare/bizarre case of using InputScalar() + integer + format string without %.
char format_sanitized[32];
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
{
format = type_info->ScanFmt;
}
else
{
format = ImParseFormatSanitizeForScanning(format, format_sanitized, IM_COUNTOF(format_sanitized));
if (format[0] == '\0')
format = type_info->ScanFmt; // Format doesn't want us to show the number currently, but we still need to parse the resulting input
}
// Small types need a 32-bit buffer to receive the result from scanf()
int v32 = 0;