How do i make the cursor focus on the widget?

So basically, i made a function that make my widget show up and hide and the mouse do the same thing. But i want my mouse when is on the widget to not go through it and move the camera. I want it to basically do nothing.

Basically not do this: