Skip to main content

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:
Call accept_event() to mark an input as handled and prevent it from propagating to nodes below.

Input Event Types

Mouse Filtering

Control how a control responds to mouse events using mouse_filter:

Mouse Filter Modes

If you place an icon on top of a button, set the icon’s mouse_filter to MOUSE_FILTER_IGNORE so clicks reach the button.

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:
Use set_drag_preview() in _get_drag_data() to create a visual representation that follows the cursor during drag.

Cursor Shapes

Change the mouse cursor appearance when hovering over controls:

Available Cursor Shapes

  • CURSOR_ARROW - Standard arrow
  • CURSOR_IBEAM - Text edit cursor
  • CURSOR_POINTING_HAND - Pointing hand (for clickable items)
  • CURSOR_CROSS - Crosshair
  • CURSOR_WAIT - Busy/waiting cursor
  • CURSOR_BUSY - Busy cursor (animated)
  • And more…

Tooltips

Display tooltips on hover:
Custom tooltips with _make_custom_tooltip():

Best Practices

When you handle an input event completely, call accept_event() to prevent it from propagating to other nodes or being processed as unhandled input.
Many controls provide high-level signals (like pressed for Button) that are cleaner than handling raw input events.
Test your UI with mouse, keyboard, touch, and gamepad to ensure accessibility.
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