窗格上的javafx事件传播
在我的javafx项目中,我有一个fxml布局文件窗格上的javafx事件传播,javafx,scroll,pane,Javafx,Scroll,Pane,在我的javafx项目中,我有一个fxml布局文件 <AnchorPane xmlns:fx="http://javafx.com/fxml/1" id="anchorPane" fx:controller="plane.splitting.PlaneSplittingController"> <BorderPane AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" id="anchorPane" fx:controller="plane.splitting.PlaneSplittingController">
<BorderPane AnchorPane.bottomAnchor="30.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<center>
<ScrollPane>
<Canvas height="500" width="500" fx:id="canvas"></Canvas>
</ScrollPane>
</center>
</BorderPane>
<BorderPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
</BorderPane>
因此,我在第一个BorderPane中的ScrollPane内有一个画布,第二个BorderPane位于第一个BorderPane上,当我试图通过滚动条用鼠标滚动滚动滚动滚动窗格时,它阻止滚动窗格滚动。我怎样才能解决这个问题?我想我需要创建第二个边框窗格,以便将所有事件传播到第一个窗格。您的第二个
边框窗格
位于第一个边框窗格
之上,这会阻止后者接收鼠标事件。@Slaw谢谢,我注意到了这一点。我试过MouseTransparent=“true”,但是它会使第二个边界窗格中的其他元素变得不负责任,为什么不这样做呢?Slaw我已经将两个边界窗格合并为一个。这是另一个解决方案:)请注意,AnchorPane
可能比它的价值更麻烦,因为你必须绝对定位它的子元素。使用能够自动定位和调整其子级大小的布局,可以产生响应性更强的UI。