Moved、Pressed、Draggedなどのマウスイベントのハンドラーを含むJavaFXの装飾されていないシーンがあり、ウィンドウのサイズ変更と移動を実装しています。ウィンドウのルート ペインは AnchorPane です。
問題は以下にあります。ルート ペインに ScrollPane を追加すると、ユーザーにウィンドウのサイズ変更を提供できません。これは、スクロールがマウス イベントを処理しているためです。また、上部ペインのマウスをトラバース可能にし、マウスイベントをルートペインから上部レイヤーに戻そうとしても、この機能に到達できません。
この問題を解決する方法を見つけるのを手伝っていただけませんか? 装飾されていないウィンドウを使用し、スクロールペイン領域も使用することが強く要求されます。
ありがとうございました!
ルートペインのコード:
<AnchorPane fx:id="mainPanelRoot" prefHeight="700.0" prefWidth="1020.0"
xmlns:fx="http://javafx.com/fxml"
fx:controller="com.intellijustice.ui.controllers.IntelliJusticeController">
<children>
<AnchorPane fx:id="mainPanel" focusTraversable="true"
AnchorPane.bottomAnchor="32.0"
AnchorPane.leftAnchor="32.0"
AnchorPane.rightAnchor="32.0"
AnchorPane.topAnchor="32.0"
onKeyPressed="#anchorPaneKeyPressed"
onMouseMoved="#anchorPaneMouseMoved"
onMousePressed="#anchorPaneMousePressed"
onMouseDragged="#anchorPaneMouseDragged">
<children>
<ToolBar fx:id="toolBar"
AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0"
prefHeight="70.0" minHeight="70.0" maxHeight="70.0"
onMouseClicked="#toolBarMouseClicked"
onMousePressed="#toolBarMousePressed"
onMouseDragged="#toolBarMouseDragged">
<ModuleBar fx:id="moduleBar">
<HBox.margin>
<Insets top="20.0" right="0.0" bottom="0.0" left="0.0"/>
</HBox.margin>
</ModuleBar>
</ToolBar>
<StackPane fx:id="moduleRegion"
AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="70.0"
AnchorPane.bottomAnchor="0.0" />
</children>
</AnchorPane>
</children>
</AnchorPane>
このルート ペインは、任意の「モデル」ペインを moduleRegion に追加できます。このモデルは、この質問の例として、いくつかのコンテンツ、スクロール ペインを含むペインです。示されているように、ルート ペインにはオーバーライドされたマウス ハンドラが含まれています。コードが大きすぎて質問に含めることができません。
スクロール ペインは、スクロール ペインが配置された単なる HBox ペインであり、マウス ハンドラはありません。