InputText: adding clarifying note about ImGuiInputTextCallbackData::Buf. (#7363)

This commit is contained in:
ocornut 2024-03-04 11:30:22 +01:00
parent fbf45ad149
commit 6b7358e9f3
1 changed files with 2 additions and 0 deletions

View File

@ -2268,6 +2268,8 @@ struct ImGuiInputTextCallbackData
void* UserData; // What user passed to InputText() // Read-only
// Arguments for the different callback events
// - During Resize callback, Buf will be same as your input buffer.
// - However, during Completion/History/Always callback, Buf always points to our own internal data (it is not the same as your buffer)! Changes to it will be reflected into your own buffer shortly after the callback.
// - To modify the text buffer in a callback, prefer using the InsertChars() / DeleteChars() function. InsertChars() will take care of calling the resize callback if necessary.
// - If you know your edits are not going to resize the underlying buffer allocation, you may modify the contents of 'Buf[]' directly. You need to update 'BufTextLen' accordingly (0 <= BufTextLen < BufSize) and set 'BufDirty'' to true so InputText can update its internal state.
ImWchar EventChar; // Character input // Read-write // [CharFilter] Replace character with another one, or set to zero to drop. return 1 is equivalent to setting EventChar=0;