import "box" as box
import "objectdraw" as od

def app = od.graphicApplicationSize (500@500)
app.startGraphics

def joe = box.named "Joe"
joe.showOn(app.canvas)
joe.moveTo(50@50)
def jill = box.named "Jill"
jill.showOn(app.canvas)
jill.moveTo(400@400)

app.onMousePressDo { event ->
    print "mouse pressed at {event.at}"
    def joeDist = joe.origin.distanceTo(event.at)
    def jillDist = jill.origin.distanceTo(event.at)
    if (joeDist < jillDist) then {
        joe.moveTo(event.at)
    } else {
        jill.moveTo(event.at)
    }
}
