You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use ImGui::InputText with ImGuiInputTextFlags_CallbackEdit in order to remove invalid character sequences from the input buffer (for example, a double slash // should change to a single slash /). In order to do this, I call data->DeleteChars(...) on the callback data. (The issue reproduces any time data->BufDirty is set to true during this kind of callback)
This works on it's own. However, inside the ImGui::InputTextEx implementation, this leads to the call state->TextA.Size = state->CurLenA + 1;, which prevents the user from adding more characters afterwards (Clicking out of the text input and back in resets the state to the correct buffer size until the callback causes the issue to appear again).
The issue can also reproduced in the Demo window. Just navigate to Widgets -> Text Input -> Completion, History, Edit Callbacks and try to enter more than one letter into the Edit Text field. The same issue also happens in the Completion Text field after hitting the tab key.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
// Code from the Demo window
struct Funcs
{
static int MyCallback(ImGuiInputTextCallbackData* data)
{
if (data->EventFlag == ImGuiInputTextFlags_CallbackEdit)
{
// Toggle casing of first character
char c = data->Buf[0];
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) data->Buf[0] ^= 32;
data->BufDirty = true;
}
return 0;
}
};
static char buf3[64];
ImGui::InputText("Edit", buf3, 64, ImGuiInputTextFlags_CallbackEdit, Funcs::MyCallback);
// Try to type more than two letters, eg "ImGui", into the text input
The text was updated successfully, but these errors were encountered:
Ah, thanks, I can confirm it's fixed in that version :) Sorry for the hassle, I just came back from a 3 weeks vacation and didn't see the new version :)
Version/Branch of Dear ImGui:
Version 1.91.3, Branch: docking
Back-ends:
Custom
Compiler, OS:
Windows 11 / MSVC
Full config/build information:
Details:
My Issue:
I'm trying to use
ImGui::InputText
withImGuiInputTextFlags_CallbackEdit
in order to remove invalid character sequences from the input buffer (for example, a double slash//
should change to a single slash/
). In order to do this, I calldata->DeleteChars(...)
on the callback data. (The issue reproduces any timedata->BufDirty
is set to true during this kind of callback)This works on it's own. However, inside the
ImGui::InputTextEx
implementation, this leads to the callstate->TextA.Size = state->CurLenA + 1;
, which prevents the user from adding more characters afterwards (Clicking out of the text input and back in resets the state to the correct buffer size until the callback causes the issue to appear again).The issue can also reproduced in the Demo window. Just navigate to
Widgets -> Text Input -> Completion, History, Edit Callbacks
and try to enter more than one letter into theEdit
Text field. The same issue also happens in the Completion Text field after hitting the tab key.Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: