InputTextMultiline: fixed losing revert value when activating scrollbar. (toward #9308)

This commit is contained in:
ocornut
2026-03-20 15:39:02 +01:00
parent 2d957152e4
commit 04dfcd838b
2 changed files with 7 additions and 3 deletions

View File

@@ -86,7 +86,8 @@ Other Changes:
for vertical scrollbar range would be +1 when the widget is inactive, word-wrap is for vertical scrollbar range would be +1 when the widget is inactive, word-wrap is
disabled and the text buffer ends with '\n'. Fixed a similar issue related to clipping disabled and the text buffer ends with '\n'. Fixed a similar issue related to clipping
large amount of text. large amount of text.
- InputTextMultiline: avoid going through reactivation code when activating scrollbar. - InputTextMultiline: avoid going through reactivation code and fixed losing revert value
when activating scrollbar.
- Style: - Style:
- Border sizes are now scaled (and rounded) by ScaleAllSizes(). - Border sizes are now scaled (and rounded) by ScaleAllSizes().
- When using large values with ScallAllSizes(), the following items thickness - When using large values with ScallAllSizes(), the following items thickness

View File

@@ -4806,8 +4806,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
// From the moment we focused we are normally ignoring the content of 'buf' (unless we are in read-only mode) // From the moment we focused we are normally ignoring the content of 'buf' (unless we are in read-only mode)
const int buf_len = (int)ImStrlen(buf); const int buf_len = (int)ImStrlen(buf);
IM_ASSERT(((buf_len + 1 <= buf_size) || (buf_len == 0 && buf_size == 0)) && "Is your input buffer properly zero-terminated?"); IM_ASSERT(((buf_len + 1 <= buf_size) || (buf_len == 0 && buf_size == 0)) && "Is your input buffer properly zero-terminated?");
state->TextToRevertTo.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string. if (!user_scroll_finish)
memcpy(state->TextToRevertTo.Data, buf, buf_len + 1); {
state->TextToRevertTo.resize(buf_len + 1); // UTF-8. we use +1 to make sure that .Data is always pointing to at least an empty string.
memcpy(state->TextToRevertTo.Data, buf, buf_len + 1);
}
// Preserve cursor position and undo/redo stack if we come back to same widget // Preserve cursor position and undo/redo stack if we come back to same widget
// FIXME: Since we reworked this on 2022/06, may want to differentiate recycle_cursor vs recycle_undostate? // FIXME: Since we reworked this on 2022/06, may want to differentiate recycle_cursor vs recycle_undostate?