InputText: Fixed an assert when using ImGuiInputTextFlags_ReadOnly and making underlying contents shorter while text is selected. (#9069)
This commit is contained in:
@@ -87,6 +87,9 @@ Other Changes:
|
|||||||
keys in order to allow e.g. external Shortcut override behavior. (#9004)
|
keys in order to allow e.g. external Shortcut override behavior. (#9004)
|
||||||
- When using a callback to reduce/manipulate the value of BufTextLen,
|
- When using a callback to reduce/manipulate the value of BufTextLen,
|
||||||
we do not require anymore that CursorPos be clamped by user code. (#9029)
|
we do not require anymore that CursorPos be clamped by user code. (#9029)
|
||||||
|
- Fixed an assert when using ImGuiInputTextFlags_ReadOnly and making
|
||||||
|
underlying contents shorter while text is selected. (#9069, #3237)
|
||||||
|
(regression from 1.92.3)
|
||||||
- InputTextMultiline: fixed a crash when using ImGuiInputTextFlags_WordWrap and
|
- InputTextMultiline: fixed a crash when using ImGuiInputTextFlags_WordWrap and
|
||||||
resizing the parent window while keeping the multi-line field active (which is
|
resizing the parent window while keeping the multi-line field active (which is
|
||||||
most typically achieved when resizing programmatically or via a docking layout
|
most typically achieved when resizing programmatically or via a docking layout
|
||||||
|
|||||||
+4
-5
@@ -4762,8 +4762,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
state->TextLen = new_len;
|
state->TextLen = new_len;
|
||||||
memcpy(state->TextA.Data, buf, state->TextLen + 1);
|
memcpy(state->TextA.Data, buf, state->TextLen + 1);
|
||||||
state->Stb->select_start = state->ReloadSelectionStart;
|
state->Stb->select_start = state->ReloadSelectionStart;
|
||||||
state->Stb->cursor = state->Stb->select_end = state->ReloadSelectionEnd;
|
state->Stb->cursor = state->Stb->select_end = state->ReloadSelectionEnd; // will be clamped to bounds below
|
||||||
state->CursorClamp();
|
|
||||||
}
|
}
|
||||||
else if ((init_state && g.ActiveId != id) || init_changed_specs)
|
else if ((init_state && g.ActiveId != id) || init_changed_specs)
|
||||||
{
|
{
|
||||||
@@ -4803,9 +4802,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
|
|
||||||
// Recycle existing cursor/selection/undo stack but clamp position
|
// Recycle existing cursor/selection/undo stack but clamp position
|
||||||
// Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler.
|
// Note a single mouse click will override the cursor/position immediately by calling stb_textedit_click handler.
|
||||||
if (recycle_state)
|
if (!recycle_state)
|
||||||
state->CursorClamp();
|
|
||||||
else
|
|
||||||
stb_textedit_initialize_state(state->Stb, !is_multiline);
|
stb_textedit_initialize_state(state->Stb, !is_multiline);
|
||||||
|
|
||||||
if (!is_multiline)
|
if (!is_multiline)
|
||||||
@@ -4862,6 +4859,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
// Read-only mode always ever read from source buffer. Refresh TextLen when active.
|
// Read-only mode always ever read from source buffer. Refresh TextLen when active.
|
||||||
if (is_readonly && state != NULL)
|
if (is_readonly && state != NULL)
|
||||||
state->TextLen = (int)ImStrlen(buf);
|
state->TextLen = (int)ImStrlen(buf);
|
||||||
|
if (state != NULL)
|
||||||
|
state->CursorClamp();
|
||||||
//if (is_readonly && state != NULL)
|
//if (is_readonly && state != NULL)
|
||||||
// state->TextA.clear(); // Uncomment to facilitate debugging, but we otherwise prefer to keep/amortize th allocation.
|
// state->TextA.clear(); // Uncomment to facilitate debugging, but we otherwise prefer to keep/amortize th allocation.
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user