Process to pick an object in the scene using mouse click, fired from button


I have a plugin with UI, written in C#, that has an ‘eyedropper’ button to pick an object in the scene. The problem is I don’t know how to implement that logic - I want to press the button and then show an arrow or finger cursor until an object is clicked or the escape key is pressed. I also want this to run as a modal operation - any other action should cancel it, for example.

This is easy in 3D Studio Max, where I am porting this tool from, but I cannot determine how to do it here in Maya 2018. Any examples in any language are welcome. Thanks so much.