Mouse

Category: Listener Tier: Basic

Purpose

Detects mouse buttons, movement, wheel, and hover events.

Visual Reference

As added to your scene
Mouse brick as it appears in the GDLink editor

When To Use

  • Follow-mouse and strafe-style 2D control graphs.

  • Capture mouse position into variables for indirect targeting.

  • Read wheel and delta values into gameplay logic without custom code.

  • Feed {prefix}_world_2d or {prefix}_position directly into Servo or into Track To position-variable mode for top-down/tower-style targeting.

Runtime Behavior

Triggers: Based on the selected mouse event and input mode.

  • Buttons support While Held, On Press, and On Release.

  • Movement and wheel events use the runtime mouse_state cache.

  • Hover supports both Mouse Over and Mouse Over Any.

  • invert=true flips the final active state like other listeners.

Generated UI Mockup — showing expanded properties
Mouse
-
x
Name:
Label this brick...
Invert
Mouse Event:
v
Input Mode:
v
Tap Mode:
v
Movement Threshold:
v
Wheel Sensitivity:
v
Expose Mouse Data:
v
Expose Scope:
v
Expose Prefix:
v
Lock To Center:
v
Keep In Screen:
v

Properties

Property

Type

Default

Notes

mouse_event

option, Left Button

Event to detect.

input_mode

option, On Press

Button trigger mode.

tap_mode

bool, false

Legacy compatibility flag.

movement_threshold

float, 1.0

Minimum movement delta for movement events.

wheel_sensitivity

float, 1.0

Sensitivity multiplier for wheel events.

expose_mouse_data

bool, false

Write sampled mouse data into runtime variables.

expose_scope

option, Local

Write exposed values to Local or Global.

expose_prefix

string, mouse

Prefix used for exposed variable names.

lock_to_center

bool, false

Captures the cursor for FPS-style control.

keep_in_screen

bool, false

Confines the cursor inside the window.

Notes

  • Native implementation: src/listeners/mouse_listener.cpp

  • gdlink_runtime.gd maintains mouse_state with:

  • mouse_position

  • mouse_position_world_2d

  • mouse_delta

  • wheel_delta

  • mouse_position and mouse_position_world_2d are refreshed every runtime tick, not only on mouse motion, so Camera2D zoom/offset and viewport changes remain reflected in exposed variables.

  • Exposed values are sampled every tick when expose_mouse_data=true, even if the selected mouse event is not currently firing. Event firing still controls whether the listener output passes to gates.