MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / input_int_field

Function input_int_field

src/host/ui/text_input.cpp:77–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77bool input_int_field(const char* label, int& value) {
78 // Reflect the committed value into a fresh per-call text buffer: while
79 // the widget is focused, ImGui edits its own persistent (ID-keyed)
80 // buffer and ignores this one, only writing back into it (and returning
81 // true) when the text actually changes. So this does not clobber an
82 // in-progress edit like "-" on the frames before it parses.
83 std::string text = std::to_string(value);
84 if (!input_text_line(label, text)) {
85 return false;
86 }
87 if (const std::optional<int> parsed = parse_int_field(text)) {
88 value = *parsed;
89 return true;
90 }
91 return false;
92}
93
94std::optional<int> parse_int_field(std::string_view text) {
95 constexpr std::string_view whitespace = " \t\n\r\f\v";

Callers 1

draw_goto_axis_fieldFunction · 0.85

Calls 2

input_text_lineFunction · 0.85
parse_int_fieldFunction · 0.85

Tested by

no test coverage detected