public final class TLcdFXEventFilterBuilder extends Object
A builder to create JavaFX Event
filters. Event filters can be useful when constructing
controller chains (see ALspController.setFXFilter(ILcdFilter)
).
Filters can be combined using the operators
and()
and or()
. By using openBrackets()
and closeBrackets()
it is possible to control which operators will be evaluated first. Operators between brackets
will be evaluated before any others, otherwise and
will be evaluated before
or
. For instance the following statement:
TLcdFXEventFilterBuilder
.newBuilder()
.openBrackets().leftMouseButton().or().rightMouseButton().closeBrackets()
.and()
.altFilter(true)
.build();
will return a filter that will let both left or right mouse button events pass, but only if
alt is down too. Without the brackets, left mouse button events would
always pass but right mouse button events only when alt is down.
The AWT equivalent of this class is TLcdAWTEventFilterBuilder
.
Modifier and Type | Method and Description |
---|---|
TLcdFXEventFilterBuilder |
altFilter(boolean aAltDown)
Adds a alt down InputEvent filter.
|
TLcdFXEventFilterBuilder |
and()
Operator to be called between two filter calls to indicate the event must pass both filters.
|
ILcdFilter<javafx.event.Event> |
build()
Builds the filter.
|
TLcdFXEventFilterBuilder |
closeBrackets()
Ends a new subfilter, all filters and operators called between this call and the previous call to
openBrackets will be evaluated together before operators and filters
outside the brackets are evaluated. |
TLcdFXEventFilterBuilder |
ctrlFilter(boolean aCtrlDown)
Adds a ctrl (cmd on macOS) down InputEvent filter.
|
TLcdFXEventFilterBuilder |
customFilter(ILcdFilter<javafx.event.Event> aFilter)
Adds a custom filter.
|
TLcdFXEventFilterBuilder |
keyEvents()
A filter that only allows key events to pass.
|
TLcdFXEventFilterBuilder |
leftMouseButton()
Adds a left mouse button filter.
|
TLcdFXEventFilterBuilder |
middleMouseButton()
Adds a middle mouse button filter.
|
TLcdFXEventFilterBuilder |
mouseEvents()
A filter that only allows mouse and scroll events to pass.
|
TLcdFXEventFilterBuilder |
mouseWheelFilter()
A filter that only allows mouse wheel events to pass.
|
static TLcdFXEventFilterBuilder |
newBuilder()
Returns a new JavaFX event filter builder.
|
TLcdFXEventFilterBuilder |
openBrackets()
Starts a new subfilter, all filters and operators called between this call and the next call to
closeBrackets will be evaluated together before operators and filters
outside the brackets are evaluated. |
TLcdFXEventFilterBuilder |
or()
Operator to be called between two filter calls to indicate the event must pass one of the two filters.
|
TLcdFXEventFilterBuilder |
rightMouseButton()
Adds a right mouse button filter.
|
TLcdFXEventFilterBuilder |
shiftFilter(boolean aShiftDown)
Adds a shift down InputEvent filter.
|
TLcdFXEventFilterBuilder |
touchEvents()
A filter that only allows touch events to pass.
|
public static TLcdFXEventFilterBuilder newBuilder()
public TLcdFXEventFilterBuilder or()
public TLcdFXEventFilterBuilder and()
public TLcdFXEventFilterBuilder openBrackets()
closeBrackets
will be evaluated together before operators and filters
outside the brackets are evaluated.public TLcdFXEventFilterBuilder closeBrackets()
openBrackets
will be evaluated together before operators and filters
outside the brackets are evaluated.public ILcdFilter<javafx.event.Event> build()
public TLcdFXEventFilterBuilder customFilter(ILcdFilter<javafx.event.Event> aFilter)
aFilter
- the filter to add to this builder.public TLcdFXEventFilterBuilder leftMouseButton()
public TLcdFXEventFilterBuilder middleMouseButton()
public TLcdFXEventFilterBuilder rightMouseButton()
public TLcdFXEventFilterBuilder ctrlFilter(boolean aCtrlDown)
aCtrlDown
- if true only events with a ctrl down mask pass, otherwise only events without
ctrl down mask.public TLcdFXEventFilterBuilder altFilter(boolean aAltDown)
aAltDown
- if true only events with a alt down mask pass, otherwise only events without
alt down mask.public TLcdFXEventFilterBuilder shiftFilter(boolean aShiftDown)
aShiftDown
- if true only events with a shift down mask pass, otherwise only events without
shift down mask.public TLcdFXEventFilterBuilder mouseWheelFilter()
public TLcdFXEventFilterBuilder touchEvents()
public TLcdFXEventFilterBuilder mouseEvents()
public TLcdFXEventFilterBuilder keyEvents()