1

When a parent component has transparent mouse enabled all child controls are no longer able to receive mouse events. Is it possible exclude a child from this rule.

public class TransparentMouseTest extends Application
{
  public static void main(String[] args)
  {
    Application.launch(args);
  }

  @Override
  public void start(Stage stage)
  {
    Pane root = new StackPane();
    root.getChildren().add(new TextField());

    Pane p = new StackPane();
    p.setMouseTransparent(true);
    p.setStyle("-fx-background-color:#F001;");
    p.getChildren().add(new Button("Button should be able \nto receive mouse events."));
    root.getChildren().add(p);

    Scene scene = new Scene(root, 400, 300);
    stage.setScene(scene);
    stage.show();
  }
}
wzberger
  • 923
  • 6
  • 15
  • 1
    Possible duplicate of [JavaFX Pass MouseEvents through Transparent Node to Children](http://stackoverflow.com/questions/16876083/javafx-pass-mouseevents-through-transparent-node-to-children) – OttPrime Feb 19 '16 at 21:09
  • Thanks for the link, #setPickOnBounds(false) works fine as long as the background is completely transparent. However, good enough for me. – wzberger Feb 19 '16 at 22:01

0 Answers0