Allow clicks only on specific UI elements

Hello,

I have read several posts but I have not managed to make it work.

I have a Canvas with several elements. I want to do the following:

  • Clicks should not be passed as actions in the code. Currently if I click in the canvas it seems to pass through as an action so I see some results I should not be seen.
  • Allow only specific UI elements to be clicked e.g. I have a text input field so upon click it should just allow me to type.

Any suggestions welcome

I think I found a workaround that seems so far to work as expected

if(userInput == null || userInput == “”)
{
inputField.ActivateInputField();
return;
}

Quite simply if mouse is clicked (and therefore there is no string input) I simply activate the input field (therefore I can still type) and exit the function that accepts the user input. So no clicks are sent further down