Game Window losses focus when clicking on the ground

I am making an FPS/RTS . When in the RTS Mode , after showing mouse cursor , when clicking on the ground , the entire game window losses focus, causing my mouse to move out of the window. How do i prevent this?

I’m not entirely sure how does the Focus Game Viewport node works in blueprint. It doesn’t seems to work for my case. Even if i do it in on tick my mouse still goes out of the window. Is there a surefire command that locks the mouse in the game again if need to .