Status: Accepted
Owner: atdi...@gmail.com
Labels: Type-Defect Priority-Medium Component-Extras

New issue 235 by atdi...@gmail.com: PSwingEventHandler doesn't dispatch events to nodes at extreme scales
http://code.google.com/p/piccolo2d/issues/detail?id=235

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?





--
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to