如何让孩子控制接收鼠标事件?

时间:2016-02-19 20:56:29

标签: javafx mouseevent javafx-8

当父组件启用透明鼠标时,所有子控件都不再能够接收鼠标事件。是否可以将儿童排除在此规则之外。

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

0 个答案:

没有答案