Slot.Connect problem

Godot Version

4.x

Question

Hi everyone,

I’ve just started working with Godot and am using C#. I’ve run into a problem while trying to create an inventory system. I’m having trouble with a function that I’m trying to make work with Connect(). Specifically, I’m stuck on how to properly handle or pass the OnSlotGuiInput function.

Can anyone help me figure out how to get this working?:

using Godot;
using System;

public partial class inventory : Node2D
{

private PackedScene _itemScene = GD.Load<PackedScene>("res://Item.tscn");
public bool isholding = false;
private GridContainer _gridContainer;

public override void _Ready()
	{
		_gridContainer = GetNode<GridContainer>("InventoryBack/GridContainer");
		var slots = _gridContainer.GetChildren();

		for (int i = 0; i < slots.Count; i++)
		{
			slots[i].Connect("gui_input", new Callable(this, nameof(OnSlotGuiInput)));
		}

	}


public void OnSlotGuiInput(InputEvent @event, Panel slot){
	if (@event is InputEventMouseButton mouseEvent && mouseEvent.ButtonIndex == MouseButton.Left && mouseEvent.Pressed)
	{
		if (isholding)
		{
			//putItem(slot);
		} else {
			//getItem(slot);
			isholding = true;
		}
	}
}

public void getItem(Panel slot){
	slot.GlobalPosition = GetGlobalMousePosition();
	

}
public void putItem(Panel slot){
	slot.GlobalPosition = GetGlobalMousePosition();
}

}