Prevent from click on gameobject behind a button

Hello,

I have scene with an ui document with some buttons, on my scene I have some monster and when I click on it (OnMouseDown) I launch a fight, but if I click on a button and the monster are behind the button, the fight are launched.
I try to use event stoppropgation on button click, but it doesn’t work, EventSystem.current.IsPointerOverGameObject() doesn’t work too.
It seems the gameobject get the event before the button.

What is the solution to prevent the event from propagating to what is behind the button ?

Finally I found a solution with panel pick

On my monster script

   public static IPanel panel;
   void OnMouseDown()
    {
        bool clickOnUi = false;
        if (panel != null)
        {
            var height = Screen.height;
            Vector3 mousePos = Input.mousePosition;
            // panel pos start from bottom but mouse pos start from top
            // so we need to get screen height - mousePos.y
            var vector3 = new Vector3(mousePos.x, height - mousePos.y);
            var element = panel.Pick(vector3);
            clickOnUi = element != null;
            Debug.Log("element clicked : " + element);
        }
        if (!clickOnUi)
        {
            Debug.Log("on ennemy");
            LoadFight();
        }
    }

On the script linked with my Uidocument I get the panel from root element and set monster panel from it

If you want ignore some UIElement just change picking mode to ignore, the method panel.Pick will ignore it

8878446--1212801--picking.png