User Tools

Site Tools


addons:functions:imgui.imguitexteditcallbackdata

ImGuiTextEditCallbackData

The ImGuiTextEditCallbackData structure contains information used for an InputText callback function. This can be useful for determining the type of callback that was fired as well as what data was used to cause the callback. The following data is exposed in this structure, to Lua addons:

struct ImGuiTextEditCallbackData
{
    ImGuiInputTextFlags EventFlags;    // ImGuiInputTextFlags_Callback... value from the ImGuiInputTextFlags_ enumeration. (Read Only)
    ImGuiInputTextFlags Flags;         // The flags of the input creation call. (Read Only)
    bool                ReadOnly;      // The readonly flag of the input box. (Read Only)
    ImWchar             EventChar;     // The character that was input.
    ImGuiKey            EventKey;      // The key pressed to cause this event. (Read Only)
    char*               Buf;           // The current buffer of text in the input.
    int                 BufTextLen;    // The current length of text in buf.
    int                 BufSize;       // Maximum length that buf can hold. (Read Only)
    bool                BufDirty;      // Must be set to true if Buf or BufTextLen is modified.
    int                 CursorPos;     // The current carrot position within the input text.
    int                 SelectionStart;// The selection start position.
    int                 SelectionEnd;  // The selection end position.
 
    void DeleteChars(int pos, int count);
    void InsertChars(int pos, const char* new_text);
    bool HasSelection();
};

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.

addons/functions/imgui.imguitexteditcallbackdata.txt · Last modified: 2016/06/27 12:27 by atom0s