Package pamViewFX.fxNodes.picker
Class ClickRepeater
java.lang.Object
pamViewFX.fxNodes.picker.ClickRepeater
Usually a
ButtonBase
only fires once per mouse click, namely when the mouse is released.
This class allows a ButtonBase
to periodically fire while armed, e.g. while the mouse is pressed.
While the button is armed, it waits 500ms to fire the first time. After that it fires every 80ms by default.
Therefore it mimics the behavior of key press events as they fire constantly, too, while the key is pressed.
Sample Usage
Button button = new Button("I'll fire constantly");
button.setOnAction(new EventHandler<ActionEvent>()} {
@Override
public void handle(ActionEvent actionEvent) {
System.out.println("Fired!");
}
});
ClickRepeater.install(button);
- Author:
- Christian Schudt
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
install
(javafx.scene.control.ButtonBase buttonBase) Installs the click repeating behavior for aButtonBase
.static void
install
(javafx.scene.control.ButtonBase buttonBase, javafx.util.Duration interval) Installs the click repeating behavior for aButtonBase
and also allows to set a click interval.static void
uninstall
(javafx.scene.control.ButtonBase buttonBase) Uninstalls the click repeater behavior from a button.
-
Method Details
-
install
public static void install(javafx.scene.control.ButtonBase buttonBase) Installs the click repeating behavior for aButtonBase
. The default click interval is 80ms.- Parameters:
buttonBase
- The button.
-
install
public static void install(javafx.scene.control.ButtonBase buttonBase, javafx.util.Duration interval) Installs the click repeating behavior for aButtonBase
and also allows to set a click interval.- Parameters:
buttonBase
- The button.interval
- The click interval.
-
uninstall
public static void uninstall(javafx.scene.control.ButtonBase buttonBase) Uninstalls the click repeater behavior from a button.- Parameters:
buttonBase
- The button.
-