Inventory GUI Box click

Hey guys,
I try to create an inventory system for my game and everything works so far. But there ist still a problem left! I draw my inventory by:

C#:

public void OnGUI() {
		GUI.skin = skin;
		if(draw) {
			int i = 0;
			for(int x = 0; x < slotsY; x++) {
				for(int y = 0; y < slotsX; y++) {
					GUI.Box(new Rect(y * 42, x * 42, 40, 40), inventory*.itemName, skin.GetStyle("slot"));*

_ GUI.DrawTexture(new Rect(y * 42, x * 42, 40, 40), inventory*.texture);_
_
i++;_
_
}*_

* }*

* }*

* }*
and now I want to know how to listen for a click on the boxes and how to find out which box / slot was clicked.
Hope you can help me! Thanks in advance

Use GUI.Button instead, using your icon texture:

You might even want to differ between left/right click, so heres what you might end up with:

if (GUI.Button(new Rect(y * 42, x * 42, 40, 40), inventory_.itemName, inventory*.texture)*_

{
if (Event.current.button == 0)
UseItem(inventory*);*
else if (Event.current.button == 1)
ShowItemInfo(inventory*);*
}
Have a great day and good coding!
-Seneral