How do you lock the mouse to the viewport?

I’m attempting to keep the mouse cursor from moving off the screen using blueprints by setting the input mode to Game & UI and setting the boolean to true. This works but after the first click the mouse is no longer bound to the viewport and can move off-screen.

The game being focused or unfocused to a widget seems irrelevant and re-setting the input mode after a click provides undesired results.

I’ve tried looking at the Strategy example but can’t make sense of the method they use in C++.

Any help from someone whose cracked this would be appreciated.