How do I lock mouse in window?

Get the mouse position? I am not sure you can focus a specific widget… get mouse position and set mouse position can be your helper I guess if there is… Sorry if I did not help at all…