How do I listen to mouse events in 2D editor?

Godot Version 4.2.1

How do I listen for mouse events?

I am making node which can add points to make lines. Now I need to change point positions in the 2d editor. So I want to know position of mouse events.

class_name Path extends Node2D

@export var points = PackedVector2Array():
		points = value

var _control_r = 20.0

func _input(event):
	if event is InputEventMouseButton:
		if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:

func _draw():
	# Drawing the lines
	for i in range(1, points.size()):
		var point1 = points[i - 1]
		var point2 = points[i]
		draw_line(point1, point2, Color.GREEN, 4.0)
	# Drawing the control points
	for point in points:
		draw_circle(point, _control_r, Color.BLUE)

This is not printing it. Please help me with this.

looks like you will need to make it as a @tool, in your case. tested it works adding point and set it, but not mouse event
you will need EditorPlugin’s _forward_canvas_gui_input

other than that i tested with Path2D and listen to its curve property changed (when adding new point as a path2d curve point) and print the global position
it works

extends Path2D
func _ready():