Depends how you want to make it.
1. But you can either you is overlapping which will make you able to teleport the object as soon as they are overlapping each other.
2. Use a distance check to see if the objects are within a certain range. Distance(Obj1.X, Obj1.Y, Obj2.X, Obj2_Y) will give you the distance between two object, you can then check if this is lower than a certain value and act on that.
If you want to make it so it based on mouse you just switch one object with Mouse.X and Mouse.Y