Area input_event not working when created from code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By TobiLa

when I use the editor to create an area node and attaching this script, the _on_area_input_event is called properly:

extends Area

func _ready():
    var rectangle_shape =
    rectangle_shape.extents = Vector3(500, 500, 2)
    var collision_shape =
    collision_shape.shape = rectangle_shape



func _on_area_input_event( camera, event, click_pos, click_normal, shape_idx ):
   pass # replace with function body

When I create the same node with the same translation etc from code by calling

var test = preload("res://")
var newTest =
# setting translation etc

The function is not called.
When viewing the live tree in the remote inspector I can’t see any difference between the nodes.

Can anyone help me to get this node working when created from code?