public final class ClickRepeater extends Object
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.
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);
Modifier and Type | Method and Description |
---|---|
static void |
install(javafx.scene.control.ButtonBase buttonBase)
Installs the click repeating behavior for a
ButtonBase . |
static void |
install(javafx.scene.control.ButtonBase buttonBase,
javafx.util.Duration interval)
Installs the click repeating behavior for a
ButtonBase and also allows to set a click interval. |
static void |
uninstall(javafx.scene.control.ButtonBase buttonBase)
Uninstalls the click repeater behavior from a button.
|
public static void install(javafx.scene.control.ButtonBase buttonBase)
ButtonBase
.
The default click interval is 80ms.buttonBase
- The button.public static void install(javafx.scene.control.ButtonBase buttonBase, javafx.util.Duration interval)
ButtonBase
and also allows to set a click interval.buttonBase
- The button.interval
- The click interval.public static void uninstall(javafx.scene.control.ButtonBase buttonBase)
buttonBase
- The button.Copyright © 2013 ExtFX. All Rights Reserved.