Lock mouse cursor in place?

Is there any way to lock the mouse cursor in place when I click on an actor? I have a function to pickup an item and when I click on it if i want to lock the mouse till I release the click.

The project is topdown.

What I want is:

when left mouse click, if an actor is there, lock the mouse cursor in place till left mouse click is released.