ScreenPointToLocalPointInRectangle not giving output

I started to make a script for touch control behavior to a UI panel. In the screen there is a UI Panel with an image component. So if I click on UI panel, the “hit” message must be shown on the console. But it doesn,t. The script is as follows.

using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine;
using UnityEngine.UI;

public class TouchControls : MonoBehaviour,IDragHandler,IPointerUpHandler,IPointerDownHandler {
    private Image Touchpanel;
    Vector3 inputVector;

	// Use this for initialization
	void Start () {
        Touchpanel = GetComponent<Image>();
	}
	

    public virtual void OnPointerDown(PointerEventData ped){
        OnDrag(ped);
    }

    public virtual void OnDrag(PointerEventData ped){
        Vector2 pos;
        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(Touchpanel.rectTransform, ped.position, ped.pressEventCamera, out pos))
        {
            Debug.Log("hit");
        }
    }

    public virtual void OnPointerUp(PointerEventData ped){
       
    }
}

What have I done wrong in the code to not get the “hit” message? Any help is valued highly.

For a RectTransform in a Canvas set to Screen Space - Overlay mode, the cam parameter should be null.