What I can do with the MOUSE function?

I want to do the following,
in a viewport, first use right button to start a menu and select a object to operate.
after select an object, I need use the right button to translate the object according to the mouse position.

What can I do since I have defined the menu with the right button, how can I use the right button to do more actions?

Use a state machine algorithm.

Thanks, but can u explain a bit more detail? coz I am not familiar with it