Getting ImGuiIO
GetIO
ImGuiIO&
Reference to the current context’s IO structure
Input Functions
Backends should call these functions to submit input events. Application code typically only reads the resulting state.
AddKeyEvent
ImGuiKey
Key identifier (e.g.,
ImGuiKey_A, ImGuiKey_Space)bool
True for key down, false for key up
AddKeyAnalogEvent
float
Analog value (typically 0.0f to 1.0f)
AddMousePosEvent
-FLT_MAX, -FLT_MAX to signify no mouse.
float
Mouse X position
float
Mouse Y position
AddMouseButtonEvent
int
Mouse button (0=left, 1=right, 2=middle)
bool
True for button down, false for button up
AddMouseWheelEvent
float
Horizontal wheel delta (positive = scroll left, negative = scroll right)
float
Vertical wheel delta (positive = scroll up, negative = scroll down)
AddMouseSourceEvent
ImGuiMouseSource
Source identifier (
ImGuiMouseSource_Mouse, ImGuiMouseSource_TouchScreen, or ImGuiMouseSource_Pen)AddFocusEvent
bool
True when application gains focus, false when it loses focus
AddInputCharacter
unsigned int
Unicode codepoint
AddInputCharactersUTF8
const char*
UTF-8 encoded string
Input Clearing
ClearEventsQueue
ClearInputKeys
ClearInputMouse
Input State Access
Mouse State
ImVec2
Mouse position in pixels. Set to
ImVec2(-FLT_MAX, -FLT_MAX) if mouse is unavailable.bool[5]
Mouse buttons state. Index 0=left, 1=right, 2=middle.
float
Mouse wheel vertical: 1 unit scrolls about 5 lines text.
Keyboard Modifiers
bool
Ctrl modifier down (non-macOS) or Cmd modifier down (macOS).
ImGuiKeyChord
Combined key modifiers flags (updated by
NewFrame()).Want Capture Flags
bool
Set when Dear ImGui will use mouse inputs. In this case, do not dispatch mouse inputs to your game/application.
bool
Set when Dear ImGui will use keyboard inputs. In this case, do not dispatch keyboard inputs to your game/application.
bool
Mobile/console: when set, you may display an on-screen keyboard. Set by Dear ImGui when it wants textual keyboard input.
bool
MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Only when
io.ConfigNavMoveSetMousePos is enabled.