How do I stop a Canvas from accepting input when not in focus?

I have two Canvases, one is a raw “world modifier” one used for the movement of player pieces on the board, but I want to create a second one as a “chat window” or an “inventory” screen. However, I’m not sure how to disable the inputs so that the back while I have this window open, the main movement canvas is not able to accept inputs.

What is the most appropriate way to get this to work? Is there a Canvas disable (that’ll stop input but not remove it from the screen) option? Or do I need a Boolean in each canvas that’s called when focus is pulled, effectively making me need to put a bool check on every input on the bottom canvas?

.enabled seems to hide the Canvas, but I’d rather keep it visible and just disable the buttons and input functionality on it while it’s “underneath”.

Use a canvas group. It has bools to set the canvas to “Interactable” and whether to block raycasts.

Make it so that it is all under an
if(in focus){
do the code
}

I don’t know the actual code for this, but it should work. This would mean that unless it is in focus it wont accept inputs

you may want to use OnMouse events

by exemple

bool mouseInside= true;

	void OnMouseEnter()
	{
		mouseInside = true;
	}

	void OnMouseExit()
	{
		mouseInside = false;

	}

this is if you want to put focus by mouse over
you can also use

	void OnMouseDown()
	{
                 locked = false;
                OtherGuiScriptReference.locked = true
	}

then your input can check the bool first to know if the gui have a focus or not