Overview
Godot’s Control nodes provide a comprehensive system for handling user input. Input events are automatically propagated through the scene tree, allowing UI elements to respond to mouse clicks, touch events, keyboard input, and more.Input events are filtered by z-order, focus state, and the
mouse_filter property before reaching a control.GUI Input Events
The _gui_input() Method
Override _gui_input() to handle input events on UI elements:
Input Event Types
Mouse Filtering
Control how a control responds to mouse events usingmouse_filter:
Mouse Filter Modes
Focus System
Only one Control can have focus at a time. The focused control receives keyboard input:Focus Navigation
Configure focus navigation between controls:Focus Modes
Handling Different Input Types
Mouse Input
Keyboard Input
Touch Input
Drag and Drop
Basic Drag and Drop
Implement drag and drop functionality using virtual methods:Cursor Shapes
Change the mouse cursor appearance when hovering over controls:Available Cursor Shapes
CURSOR_ARROW- Standard arrowCURSOR_IBEAM- Text edit cursorCURSOR_POINTING_HAND- Pointing hand (for clickable items)CURSOR_CROSS- CrosshairCURSOR_WAIT- Busy/waiting cursorCURSOR_BUSY- Busy cursor (animated)- And more…
Tooltips
Display tooltips on hover:_make_custom_tooltip():
Best Practices
Always call accept_event()
Always call accept_event()
When you handle an input event completely, call
accept_event() to prevent it from propagating to other nodes or being processed as unhandled input.Use signals over _gui_input() when possible
Use signals over _gui_input() when possible
Many controls provide high-level signals (like
pressed for Button) that are cleaner than handling raw input events.Test with multiple input devices
Test with multiple input devices
Test your UI with mouse, keyboard, touch, and gamepad to ensure accessibility.
Handle focus properly
Handle focus properly
Ensure keyboard navigation works correctly by setting up proper focus modes and neighbors.
See Also
Control Nodes
Learn about the UI elements that receive input
Themes
Customize the visual feedback for input states