Quick answer: Toggle Input.mouse_mode on every menu open/close. Add a focus-out handler to release capture when the window loses focus. Provide an Escape escape hatch for development.

Here is how to fix Godot 4 mouse mode that stays Captured after opening a menu, leaving players unable to click UI. The mode change must be paired with restore on every menu transition.

The Symptom

Game starts with mouse captured for FPS controls. Player presses Esc to open menu; cursor stays invisible. Buttons unclickable.

What Causes This

One-way set. Code sets CAPTURED on Start; never sets VISIBLE on menu open.

No focus-out handling. Alt-tab leaves capture active even when window loses focus.

State spread across scripts. Multiple scripts set mouse mode independently; conflicts.

The Fix

Step 1: Centralize mouse mode in one autoload.

# MouseManager.gd autoload
extends Node

func capture():
    Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

func release():
    Input.mouse_mode = Input.MOUSE_MODE_VISIBLE

func _notification(what):
    if what == NOTIFICATION_APPLICATION_FOCUS_OUT:
        release()

Single source of truth for mouse mode.

Step 2: Toggle on menu transitions.

func open_pause_menu():
    MouseManager.release()
    pause_menu.show()
    get_tree().paused = true

func close_pause_menu():
    pause_menu.hide()
    get_tree().paused = false
    MouseManager.capture()

Step 3: Provide Escape escape hatch in dev.

func _input(event):
    if OS.is_debug_build() and event.is_action_pressed("ui_cancel"):
        MouseManager.release()

Editor PIE never gets stuck behind a captured mouse.

Step 4: For confined mode.

Input.mouse_mode = Input.MOUSE_MODE_CONFINED   # cursor visible but limited to window

Useful for windowed strategy games where the cursor should not leave the viewport.

Step 5: Test alt-tab and reload. Capture, alt-tab away, return. Cursor should be visible during the away period and re-capture on focus or remain visible per your design.

“Centralize mouse mode. Toggle on every transition. Release on focus loss. The cursor stays sane.”

Related Issues

For Area2D monitoring on spawn, see Area2D Monitoring. For shader uniforms, see Shader Uniform Updates.

Autoload for mouse mode. Toggle each transition. Focus-out releases. No stuck cursor.