title: JavaFx canvas mouse events
body: <p>I would like to intercept mouse events on canvas only where I've drawn some shape, but in all other transparent area I would like to have behaviour like with property mouseTransparent true.
  I can achieve that with ImageView, transparent areas doesn't intercept mouse events.</p>
  
  <pre><code>public void start(Stage primaryStage) throws Exception {
      primaryStage.setTitle("Drawing Operations Test");
      Pane root = new Pane();
      root.setStyle("-fx-background-color: #C9E3AF");
      root.setMinSize(1000, 1000);
      root.setOnMouseClicked(event -&gt; {
          System.out.println("Clicked on root pane");
      });
  
      Canvas canvas1 = new Canvas(512, 512);
  
      canvas1.getGraphicsContext2D().setFill(Color.BLACK);
      canvas1.getGraphicsContext2D().fillRect(250, 250, 250, 250);
      canvas1.setOnMouseClicked(event -&gt; {
          System.out.println("Clicked on canvas1");
      });
      canvas1.setPickOnBounds(false);
  
      Canvas canvas2 = new Canvas(512, 512);
  
      canvas2.getGraphicsContext2D().setFill(Color.RED);
      canvas2.getGraphicsContext2D().fillRect(200, 200, 250, 250);
      canvas2.setOnMouseClicked(event -&gt; {
          System.out.println("Clicked on canvas2");
      });
      canvas2.setPickOnBounds(false);
  
  
      SnapshotParameters param1 = new SnapshotParameters();
  
      param1.setFill(Color.TRANSPARENT);
      WritableImage image1 = canvas1.snapshot(param1, new WritableImage(512, 512));
  
      SnapshotParameters param2 = new SnapshotParameters();
  
      param2.setFill(Color.TRANSPARENT);
      WritableImage image2 = canvas2.snapshot(param2, new WritableImage(512, 512));
  
      ImageView view1 = new ImageView(image1);
      view1.setOnMouseClicked(event -&gt; {
          System.out.println("Clicked on view1");
      });
      view1.setPickOnBounds(false);
  
      ImageView view2 = new ImageView(image2);
      view2.setOnMouseClicked(event -&gt; {
          System.out.println("Clicked on view2");
      });
      view2.setPickOnBounds(false);
  
      // ImageView test
      // root.getChildren().addAll(view1, view2);
  
      // Canvas test
      root.getChildren().addAll(canvas1, canvas2);
      Scene sc = new Scene(root);
  
      primaryStage.setScene(sc);
      primaryStage.setX(0);
      primaryStage.setY(0);
      primaryStage.show();
  }
  </code></pre>
  
  <p>Is it even possible with Canvas?</p>