title: Mouse Events get Ignored on the Underlying Layer
body: <p>I have two layers (= AnchorPanes) stacked one of the other with a StackPane. So both layer fill the whole scene. The problem is, that only the top layer receives mouse events.</p>
  
  <p>Thats how the scene is build:</p>
  
  <p><img src="https://i.stack.imgur.com/d7Me2.png" alt="Layout of the Scene"></p>
  
  <p>Only Button B receives click events but Button A not.</p>
  
  <p><img src="https://i.stack.imgur.com/4B6Bs.png" alt="Button A don&#39;t Receive Click Events"></p>
  
  <p>If I set Layer B to mouse transparent (<code>layerB.setMouseTransparent(true)</code>), Button A receives mouse events. But mouse transparent effects also all children, so Button B dont receives mouse events any more.</p>
  
  <p>How to get Button A and Button B to receive mouse events?</p>
  
  <p>Here is the full working source:</p>
  
  <pre><code>public class LayerTest extends Application {
      @Override
      public void start(final Stage primaryStage) throws Exception {
          final Node layerA = createLayerA();
          final Node layerB = createLayerB();
          final Parent root = new StackPane(layerA, layerB);
          final Scene scene = new Scene(root);
          primaryStage.setScene(scene);
          primaryStage.setWidth(250);
          primaryStage.setHeight(200);
          primaryStage.show();
      }
  
      private Node createLayerA() {
          final AnchorPane layerA = new AnchorPane();
          final Button buttonA = new Button("Button A");
          AnchorPane.setLeftAnchor(buttonA, 10d);
          AnchorPane.setTopAnchor(buttonA, 10d);
          buttonA.setOnMouseClicked(e -&gt; System.out.println("Button A clicked"));
          layerA.getChildren().setAll(buttonA);
          return layerA;
      }
  
      private Node createLayerB() {
          final AnchorPane layerB = new AnchorPane();
          final Button buttonB = new Button("Button B");
          AnchorPane.setRightAnchor(buttonB, 10d);
          AnchorPane.setBottomAnchor(buttonB, 10d);
          buttonB.setOnMouseClicked(e -&gt; System.out.println("Button B clicked"));
          layerB.getChildren().setAll(buttonB);
          return layerB;
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>