## MASON-INTEREST-L@LISTSERV.GMU.EDU

 Options: Use Proportional Font Show HTML Part by Default Show All Mail Headers Message: [<< First] [< Prev] [Next >] [Last >>] Topic: [<< First] [< Prev] [Next >] [Last >>] Author: [<< First] [< Prev] [Next >] [Last >>]

```MASON at present doesn't have built-in support for adding new objects
via the mouse, but that's just because we hadn't needed it ourselves
yet.  While you *can* compute all the coordinates yourself, it's
complex.  Each field portrayal can have its own coordinate system.

Here's how I'd do it.  In Display2D there's a method called
objectsHitBy(rect), which takes a rect (in InnerDisplay2D coordinates)
and returns LocationWrappers for all the objects in fields which
happened to fall into this region.  It does most of the math for you if
you want to cut-and-paste and modify.  The heavy lifting is done clear
to the line

p.portrayal.hitObjects( new DrawInfo2D(region,rect),
hitObjs[x] );

...at which point you'd replace this line with some appropriate code
(and probably reduce your copy of the the objectsHitBy(...) code so it
doesn't go through all the field portrayals but just the one you need).

region defines a rectangle whose <x,y> is the origin of the field, and
whose <width,height> is the scaled width and height of the field.  So
you could interpret the DrawInfo2D as saying:  "imagine if you will
that your field has been translated and stretched so that its origin
lies on <x,y> in the cartesian plane, and has been bent to a width and
height of <width,height>.  Then the area I'm interested in is the rect
'rect' in that imaginary situation."  For a mouse click, rect will
probably have a width and height of 1,1.

Sean
```