Skip to content

Commit 1500410

Browse files
ocornutmatthew-mccall
authored andcommitted
InputText: reactivating last activated InputText() doesn't restore horizontal scrolling.
Honestly not sure if the opposite is preferable or not (added commented out in the inactivate render path to test that). Current behavior added along with recycling: f9928e9
1 parent 79da8cd commit 1500410

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ Other changes:
5858
processing errors outside of the NewFrame()..EndFrame() scope. (#1651)
5959
- Tables: fixed SetNextWindowScroll() value being ignored by BeginTable() during
6060
the first frame or when scrolling flags have changed. (#8196)
61+
- InputText: reactivating last activated InputText() doesn't restore horizontal scrolling
62+
(which was disabled during deactivation anyway).
6163
- Misc: changed embedded ProggyClean encoding to save a bit of binary space (~12kb to 9.5kb).
6264
- Misc: added IMGUI_DISABLE_DEFAULT_FONT to strip embedded font from binary. (#8161)
6365
[@demonese]

Diff for: imgui_widgets.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -4537,6 +4537,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
45374537
state->TextA.resize(buf_size + 1); // we use +1 to make sure that .Data is always pointing to at least an empty string.
45384538
state->TextLen = (int)strlen(buf);
45394539
memcpy(state->TextA.Data, buf, state->TextLen + 1);
4540+
state->Scroll = ImVec2(0.0f, 0.0f);
45404541

45414542
if (recycle_state)
45424543
{
@@ -4546,7 +4547,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
45464547
}
45474548
else
45484549
{
4549-
state->Scroll = ImVec2(0.0f, 0.0f);
45504550
stb_textedit_initialize_state(state->Stb, !is_multiline);
45514551
}
45524552

@@ -5287,8 +5287,9 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
52875287

52885288
if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length)
52895289
{
5290+
const ImVec2 draw_scroll = /*state ? ImVec2(state->Scroll.x, 0.0f) :*/ ImVec2(0.0f, 0.0f); // Preserve scroll when inactive?
52905291
ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text);
5291-
draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect);
5292+
draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos - draw_scroll, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect);
52925293
}
52935294
}
52945295

0 commit comments

Comments
 (0)