Closed GoogleCodeExporter closed 9 years ago
Here's a proposed fix:
### Eclipse Workspace Patch 1.0
#P piccolo2d-core
Index: src/main/java/edu/umd/cs/piccolo/PNode.java
===================================================================
--- src/main/java/edu/umd/cs/piccolo/PNode.java (revision 617)
+++ src/main/java/edu/umd/cs/piccolo/PNode.java (working copy)
@@ -2722,7 +2722,7 @@
* @return true if this node or one of its descendents was picked.
*/
public boolean fullPick(final PPickPath pickPath) {
- if ((getPickable() || getChildrenPickable()) &&
fullIntersects(pickPath.getPickBounds())) {
+ if (getVisible() && (getPickable() || getChildrenPickable()) &&
fullIntersects(pickPath.getPickBounds())) {
pickPath.pushNode(this);
pickPath.pushTransform(transform);
Index: src/test/java/edu/umd/cs/piccolo/PNodeTest.java
===================================================================
--- src/test/java/edu/umd/cs/piccolo/PNodeTest.java (revision 617)
+++ src/test/java/edu/umd/cs/piccolo/PNodeTest.java (working copy)
@@ -29,6 +29,7 @@
package edu.umd.cs.piccolo;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GraphicsEnvironment;
import java.awt.geom.AffineTransform;
@@ -52,6 +53,7 @@
import edu.umd.cs.piccolo.activities.PTransformActivity;
import edu.umd.cs.piccolo.activities.PColorActivity.Target;
import edu.umd.cs.piccolo.event.PBasicInputEventHandler;
+import edu.umd.cs.piccolo.event.PInputEvent;
import edu.umd.cs.piccolo.util.PAffineTransform;
import edu.umd.cs.piccolo.util.PAffineTransformException;
import edu.umd.cs.piccolo.util.PBounds;
@@ -1290,4 +1292,25 @@
node.setOccluded(true);
assertTrue(node.getOccluded());
}
+
+ public void testHiddenNodesAreNotPickable() {
+ PCanvas canvas = new PCanvas();
+ canvas.setBounds(0, 0, 400, 400);
+ canvas.setPreferredSize(new Dimension(400, 400));
+ PNode node1 = new PNode();
+ node1.setBounds(0, 0, 100, 100);
+ node1.setPaint(Color.RED);
+ canvas.getLayer().addChild(node1);
+
+ PNode node2 = (PNode) node1.clone();
+ node2.setPaint(Color.BLUE);
+
+ PLayer layer2 = new PLayer();
+ layer2.addChild(node2);
+ layer2.setVisible(false);
+ canvas.getCamera().addLayer(layer2);
+
+ PPickPath path = canvas.getCamera().pick(5, 5, 5);
+ assertSame(node1, path.getPickedNode());
+ }
}
Original comment by allain.lalonde
on 29 Jul 2009 at 7:07
Fixed in r622
Original comment by allain.lalonde
on 29 Jul 2009 at 7:37
Original comment by mr0...@mro.name
on 29 Jul 2009 at 8:13
Original issue reported on code.google.com by
matthias...@gmail.com
on 29 Jul 2009 at 12:41