Class MouseClickFilter
java.lang.Object
org.jorigin.jfx.control.MouseClickFilter
- All Implemented Interfaces:
EventListener,javafx.event.EventHandler<javafx.scene.input.MouseEvent>
public class MouseClickFilter
extends Object
implements javafx.event.EventHandler<javafx.scene.input.MouseEvent>
A mouse event filter that enable to filter intermediate mouse click events when multiple clicks occur.
For example, This filter enables to produce only one MouseEvent when clicking consecutively on a button (instead of firing multiple events).
- Author:
- Julien SEINTURIER - Université de Toulon / CNRS LIS umr 7020 - github.com/jorigin/jcommon (contact@jorigin.org)
-
Constructor Summary
ConstructorsConstructorDescriptionMouseClickFilter(long delay, javafx.event.EventHandler<? super javafx.scene.input.MouseEvent> handler) Create a new mouse click filter that trigger the given handler when a click event is accepted.MouseClickFilter(javafx.event.EventHandler<? super javafx.scene.input.MouseEvent> handler) Create a new mouse click filter that trigger the given handler when a click event is accepted. -
Method Summary
Modifier and TypeMethodDescriptionlongGet the maximal time between two mouse clicks in order to consider them as consecutive.javafx.event.EventHandler<? super javafx.scene.input.MouseEvent> Get the handler that is attached to this filter.voidhandle(javafx.scene.input.MouseEvent e) Process a mouse event.voidsetClickDelay(long delay) Set the maximal time between two mouse clicks in order to consider them as consecutive.voidsetMouseClickEventHandler(javafx.event.EventHandler<? super javafx.scene.input.MouseEvent> handler) Set the handler to attach to this filter.
-
Constructor Details
-
MouseClickFilter
public MouseClickFilter(javafx.event.EventHandler<? super javafx.scene.input.MouseEvent> handler) Create a new mouse click filter that trigger the given handler when a click event is accepted.- Parameters:
handler- the handler to trigger.
-
MouseClickFilter
public MouseClickFilter(long delay, javafx.event.EventHandler<? super javafx.scene.input.MouseEvent> handler) Create a new mouse click filter that trigger the given handler when a click event is accepted.- Parameters:
delay- the maximal delay in milliseconds (ms) between two clicks to consider them as consecutive.handler- the handler to trigger.
-
-
Method Details
-
getMouseClickEventHandler
public javafx.event.EventHandler<? super javafx.scene.input.MouseEvent> getMouseClickEventHandler()Get the handler that is attached to this filter. Only accepted event are sent to the handler.- Returns:
- the handler that is attached to this filter
- See Also:
-
setMouseClickEventHandler
public void setMouseClickEventHandler(javafx.event.EventHandler<? super javafx.scene.input.MouseEvent> handler) Set the handler to attach to this filter. Only accepted event are sent to the handler.- Parameters:
handler- the handler to attach
-
getClickDelay
public long getClickDelay()Get the maximal time between two mouse clicks in order to consider them as consecutive.- Returns:
- the maximal time between two mouse clicks in order to consider them as consecutive
- See Also:
-
setClickDelay
public void setClickDelay(long delay) Set the maximal time between two mouse clicks in order to consider them as consecutive.- Parameters:
delay- the maximal time between two mouse clicks in order to consider them as consecutive
-
handle
public void handle(javafx.scene.input.MouseEvent e) Process a mouse event. When multiple events are processed in a flow, this filter will only keep single clicks or maximum consecutive click events.- Specified by:
handlein interfacejavafx.event.EventHandler<javafx.scene.input.MouseEvent>- Parameters:
e- the mouse event to process.
-