tmpkus / piccolo2d

Automatically exported from code.google.com/p/piccolo2d
0 stars 0 forks source link

PSwingEventHandler doesn't dispatch events to nodes at extreme scales #235

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
User John Marteens reported an error where a Swing component (within a PSwing) 
does not get mouse events when that component is within a node lineage that has 
extreme scale transforms.

For example, if a PSwing is within a parent node with scale = 0.001, events are 
not fired for the component. (I've reproduced this particular case on 
Win7/64bit Java).

John provided a suggested patch that fixes his particular case:

=== PSwingEventHandler ===
...
       if (currentNode instanceof PSwing && pickedNode.isDescendentOf(canvas.getRoot())) {

           final PSwing swing = (PSwing) currentNode;
           final PNode grabNode = pickedNode;

           point = new Point(mEvent.getX(), mEvent.getY());
//jmes 20111230 replaced
//            cameraToLocal(pSwingMouseEvent.getPath().getTopCamera(), point, 
grabNode);
           Point2D.Double pt2D = new Point2D.Double(mEvent.getX(), mEvent.getY());
           cameraToLocal(pSwingMouseEvent.getPath().getTopCamera(), pt2D, grabNode);
           point.setLocation(pt2D);
//jmes 20111230 end replaced
           prevPoint = (Point) point.clone();
=== END ===

Essentially, the integer Point object does not survive the cameraToLocal math. 
John found that using a Point2D.Double fixes his particular problem.

Does anyone see anything wrong with his solution?

Original issue reported on code.google.com by atdi...@gmail.com on 7 Jan 2012 at 7:20

GoogleCodeExporter commented 9 years ago

Original comment by atdi...@gmail.com on 7 Jan 2012 at 7:28

GoogleCodeExporter commented 9 years ago
Committed revision 1160. Please review/verify.

Original comment by atdi...@gmail.com on 7 Jan 2012 at 7:29

GoogleCodeExporter commented 9 years ago
Committed revision 1161. (This is the TRUNK fix.)

Original comment by atdi...@gmail.com on 7 Jan 2012 at 7:42

GoogleCodeExporter commented 9 years ago

Original comment by heue...@gmail.com on 26 Nov 2013 at 5:42