This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
addons:functions:imgui.imguitexteditcallbackdata [2016/06/27 04:44] atom0s created |
addons:functions:imgui.imguitexteditcallbackdata [2016/06/27 12:27] (current) atom0s |
||
---|---|---|---|
Line 6: | Line 6: | ||
struct ImGuiTextEditCallbackData | struct ImGuiTextEditCallbackData | ||
{ | { | ||
- | ImGuiInputTextFlags EventFlags; // ImGuiInputTextFlags_Callback... value from the ImGuiInputTextFlags_ enumeration. | + | ImGuiInputTextFlags EventFlags; // ImGuiInputTextFlags_Callback... value from the ImGuiInputTextFlags_ enumeration. (Read Only) |
- | ImGuiInputTextFlags Flags; // The flags of the input creation call. | + | ImGuiInputTextFlags Flags; // The flags of the input creation call. (Read Only) |
- | bool ReadOnly; // The readonly flag of the input box. | + | bool ReadOnly; // The readonly flag of the input box. (Read Only) |
ImWchar EventChar; // The character that was input. | ImWchar EventChar; // The character that was input. | ||
- | ImGuiKey EventKey; // The key pressed to cause this event. | + | ImGuiKey EventKey; // The key pressed to cause this event. (Read Only) |
char* Buf; // The current buffer of text in the input. | char* Buf; // The current buffer of text in the input. | ||
int BufTextLen; // The current length of text in buf. | int BufTextLen; // The current length of text in buf. | ||
- | int BufSize; // Maximum length that buf can hold. | + | int BufSize; // Maximum length that buf can hold. (Read Only) |
bool BufDirty; // Must be set to true if Buf or BufTextLen is modified. | bool BufDirty; // Must be set to true if Buf or BufTextLen is modified. | ||
int CursorPos; // The current carrot position within the input text. | int CursorPos; // The current carrot position within the input text. | ||
int SelectionStart;// The selection start position. | int SelectionStart;// The selection start position. | ||
int SelectionEnd; // The selection end position. | int SelectionEnd; // The selection end position. | ||
+ | | ||
+ | void DeleteChars(int pos, int count); | ||
+ | void InsertChars(int pos, const char* new_text); | ||
+ | bool HasSelection(); | ||
}; | }; | ||
</code> | </code> | ||
- | Lua should not attempt to edit the buffer as it can cause crashes due to how buffers are setup in this manner. Most of this structure is readonly and should only be used for reference. | + | Some fields are read-only and cannot be edited. |
+ | |||
+ | If you edit the 'Buf' field, you must update the BufTextLen to the new length as well as set BufDirty to true in order for it to be properly updated. To do this easily you can make use of the DeleteChars and InsertChars functions which will handle the property adjustments for you. | ||
+ | |||
+ | You may also want to set CursorPos to the end of the string for a more expected result. |