Never tried it but I would assume:
1. When the mouse is clicked, if it's not already in an , get it's position (then
repeat : until mouseclick()=0)
2. If it is over anything, change a variable so that it knows that the current mode is building, or digging, or whatever it is
3. Detect the current mode and paste the appropriate sprite at the mouse position. Then set the mouse variable back to 0.
Shouldn't be too hard. Just remember to create sprites every time, not just re-use the old ones, or it'll just move the sprites that are out every time.
http://jamesmason01.googlepages.com/index.htm
