ScrollPance 随节点 Javafx 移动

ScrollPance moving with node Javafx

我有一个滚动窗格,滚动窗格内有一个矩形 Pane.The 矩形只能向左或向右移动。滚动窗格的宽度为 800,当 windows 变小时,滚动条将启用,您可以滚动。我的问题是,当我尝试在滚动条打开时移动矩形时,滚动条也会向左移动或 right.Is 移动节点时临时禁用滚动功能的方法 >

我想你可能正在寻找的是

public final void setPannable(boolean value)

Sets the value of the property pannable. Property description: Specifies whether the user should be able to pan the viewport by using the mouse. If mouse events reach the ScrollPane (that is, if mouse events are not blocked by the contained node or one of its children) then pannable is consulted to determine if the events should be used for panning.

https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/ScrollPane.html#setPannable-boolean-

我不确定这是否有效,但听起来像。

您也可以使用 https://docs.oracle.com/javase/8/javafx/api/javafx/scene/Node.html#onMouseClickedProperty

或类似的 MouseProperty,设置一个 Listener 并使其在您单击 ScrollPane 时设置 https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/ScrollPane.ScrollBarPolicy.html

永远不会

public static final ScrollPane.ScrollBarPolicy NEVER

Indicates that a scroll bar should never be shown.

然后返回 ScrollPane.onMouseReleased();

的原始设置

祝你好运!