UI mouse click problem

I have a problem I’ve been struggling for last week. I’m currently making inventory system to my game and I can’t find any working way to detect mouse click on UI image. I was searching a lot and I need your help with figuring why NOTHING was working.

I won’t write about details, because that would be too long.

(If I made some mistakes in my english I’m really sorry)

I tested this quickly and it seems to work. I put this on an object with an Image component that was a child of the Canvas.
The scene needs the Event Handler which should have been automatically created when a Canvas was added to the scene.

using UnityEngine;
using UnityEngine.EventSystems;

public class UIClick : MonoBehaviour, IPointerClickHandler
{
    public void OnPointerClick(PointerEventData eventData)
    {
        Debug.Log("Detected Click!");
    }
}