Updates:
        Status: Started
        Labels: Type-Defect Priority-Critical Effort-Low OpSys-All  
Toolkit-Piccolo2D.Java Component-Core Milestone-1.3

Comment #1 on issue 113 by allain.lalonde: Invisible nodes are reported to  
be picked by InputEventHandler
http://code.google.com/p/piccolo2d/issues/detail?id=113

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());
+    }
  }


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

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

Reply via email to