How would I make a rotateable object in a viewport frame?

What I want to do is what FPS games do, if you click the viewport with the gun shown on it you cant rotate it around. How would I do this?