Class StageDragBehaviour
java.lang.Object
com.dlsc.gemsfx.util.StageDragBehaviour
Allows dragging a node's containing
Stage with the primary mouse button.
The stage is resolved when a drag starts, so the behaviour can be installed before
the node is attached to a scene or window. Nodes in non-stage windows are ignored.
Event filters are used without consuming events or replacing existing handlers.
StageDragBehaviour dragging = StageDragBehaviour.install(titleBar);
dragging.enabledProperty().bind(draggingAllowed);
// When no longer needed:
dragging.uninstall();
Install, configure, and uninstall the behaviour on the JavaFX application thread.
-
Property Summary
PropertiesTypePropertyDescriptionfinal javafx.beans.property.BooleanPropertyDetermines whether mouse dragging moves the containing stage. -
Method Summary
Modifier and TypeMethodDescriptionfinal javafx.beans.property.BooleanPropertyDetermines whether mouse dragging moves the containing stage.static StageDragBehaviourinstall(javafx.scene.Node node) Installs stage dragging on the given node, enabled by default.final booleanGets the value of theenabledproperty.booleanChecks whether this behaviour is still installed.static booleanisInstalled(javafx.scene.Node node) Checks whether stage dragging is installed on the given node.final voidsetEnabled(boolean enabled) Sets the value of theenabledproperty.voidRemoves this behaviour's event filters and cancels any active drag.
-
Property Details
-
enabled
public final javafx.beans.property.BooleanProperty enabledPropertyDetermines whether mouse dragging moves the containing stage. The default value istrue. Disabling cancels any active drag.- See Also:
-
-
Method Details
-
install
Installs stage dragging on the given node, enabled by default.- Parameters:
node- the node to use as a drag handle- Returns:
- the installed behaviour
- Throws:
NullPointerException- if the node is nullIllegalStateException- if stage dragging is already installed on the node
-
enabledProperty
public final javafx.beans.property.BooleanProperty enabledProperty()Determines whether mouse dragging moves the containing stage. The default value istrue. Disabling cancels any active drag.- Returns:
- the enabled property
- See Also:
-
isEnabled
public final boolean isEnabled()Gets the value of theenabledproperty.- Property description:
- Determines whether mouse dragging moves the containing stage.
The default value is
true. Disabling cancels any active drag. - Returns:
- the value of the
enabledproperty - See Also:
-
setEnabled
public final void setEnabled(boolean enabled) Sets the value of theenabledproperty.- Property description:
- Determines whether mouse dragging moves the containing stage.
The default value is
true. Disabling cancels any active drag. - Parameters:
enabled- the value for theenabledproperty- See Also:
-
isInstalled
public static boolean isInstalled(javafx.scene.Node node) Checks whether stage dragging is installed on the given node.- Parameters:
node- the node to check- Returns:
- true if stage dragging is installed
-
isInstalled
public boolean isInstalled()Checks whether this behaviour is still installed.- Returns:
- true if this behaviour is installed
-
uninstall
public void uninstall()Removes this behaviour's event filters and cancels any active drag. Calling this method more than once has no effect.
-