Text Input
InputText()
Single-line text input:const char*
required
Widget label
char*
required
Character buffer to edit
size_t
required
Size of the buffer (including null terminator)
ImGuiInputTextFlags
default:"0"
Optional input text flags (see below)
InputTextMultiline()
Multi-line text input:InputTextWithHint()
Text input with placeholder hint:Input Text Flags
Customize text input behavior with flags:Common flags include:
ImGuiInputTextFlags_EnterReturnsTrue- Return true when Enter pressedImGuiInputTextFlags_Password- Display as password (***)ImGuiInputTextFlags_ReadOnly- Read-only modeImGuiInputTextFlags_CharsDecimal- Allow 0-9 . + - *ImGuiInputTextFlags_CharsNoBlank- Filter out spaces and tabs
Numeric Input
InputInt()
Integer input with optional step buttons:InputFloat()
Floating-point input:InputDouble()
Double-precision input:Multi-Component Input
InputFloat2/3/4()
Input multiple float values:InputInt2/3/4()
Input multiple integer values:Generic Scalar Input
InputScalar()
Input any scalar data type:ImGuiDataType
required
Data type:
ImGuiDataType_S8,ImGuiDataType_U8ImGuiDataType_S16,ImGuiDataType_U16ImGuiDataType_S32,ImGuiDataType_U32ImGuiDataType_S64,ImGuiDataType_U64ImGuiDataType_Float,ImGuiDataType_Double
Input Validation and Callbacks
Use callbacks to validate or process input:Complete Example
Best Practices
Check
IsItemDeactivatedAfterEdit() after an input widget to detect when editing is complete and the value has changed.