mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
InputText: Added BufTextLen in ImGuiTextEditCallbackData. Requesting user to maintain it. Zero-ing structure properly before use. (#541)
This commit is contained in:
12
imgui.h
12
imgui.h
@ -944,7 +944,7 @@ struct ImGuiStorage
|
||||
IMGUI_API void SetAllInt(int val);
|
||||
};
|
||||
|
||||
// Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used.
|
||||
// Shared state of InputText(), passed to callback when a ImGuiInputTextFlags_Callback* flag is used and the corresponding callback is triggered.
|
||||
struct ImGuiTextEditCallbackData
|
||||
{
|
||||
ImGuiInputTextFlags EventFlag; // One of ImGuiInputTextFlags_Callback* // Read-only
|
||||
@ -956,15 +956,17 @@ struct ImGuiTextEditCallbackData
|
||||
ImWchar EventChar; // Character input // Read-write (replace character or set to zero)
|
||||
|
||||
// Completion,History,Always events:
|
||||
// If you modify the buffer contents make sure you update 'BufTextLen' and set 'BufDirty' to true.
|
||||
ImGuiKey EventKey; // Key pressed (Up/Down/TAB) // Read-only
|
||||
char* Buf; // Current text // Read-write (pointed data only)
|
||||
int BufSize; // // Read-only
|
||||
bool BufDirty; // Must set if you modify Buf directly // Write
|
||||
char* Buf; // Current text buffer // Read-write (pointed data only, can't replace the actual pointer)
|
||||
int BufTextLen; // Current text length in bytes // Read-write
|
||||
int BufSize; // Maximum text length in bytes // Read-only
|
||||
bool BufDirty; // Set if you modify Buf/BufTextLen!! // Write
|
||||
int CursorPos; // // Read-write
|
||||
int SelectionStart; // // Read-write (== to SelectionEnd when no selection)
|
||||
int SelectionEnd; // // Read-write
|
||||
|
||||
// NB: calling those function loses selection.
|
||||
// NB: Helper functions for text manipulation. Calling those function loses selection.
|
||||
void DeleteChars(int pos, int bytes_count);
|
||||
void InsertChars(int pos, const char* text, const char* text_end = NULL);
|
||||
bool HasSelection() const { return SelectionStart != SelectionEnd; }
|
||||
|
Reference in New Issue
Block a user