Package edu.umd.cs.piccolo.event
Class PInputEventFilter
java.lang.Object
edu.umd.cs.piccolo.event.PInputEventFilter
PInputEventFilter is a class that filters input events based on the
events modifiers and type. Any PBasicInputEventHandler that is associated
with an event filter will only receive events that pass through the filter.
To be accepted events must contain all the modifiers listed in the andMask, at least one of the modifiers listed in the orMask, and none of the modifiers listed in the notMask. The event filter also lets you specify specific event types (mousePressed, released, ...) to accept or reject.
If the event filter is set to consume, then it will call consume on any event that it successfully accepts.
- Version:
- 1.0
- Author:
- Jesse Grosjean
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic intMask representing all possible modifiers. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a PInputEventFilter that accepts everything.PInputEventFilter(int andMask) Creates a PInputEventFilter that will accept events if they have the given andMask.PInputEventFilter(int andMask, int notMask) Creates a PInputEventFilter that will accept events if they have the given andMask and do not contain any of the bits in the notMask. -
Method Summary
Modifier and TypeMethodDescriptionvoidMakes this filter accept all mouse click combinations.voidMakes the filter accept all event types.voidMakes this filter accept absolutely everything.booleanacceptsEvent(PInputEvent event, int type) Returns true if the passed event is one that is accepted.booleanReturns whether this filter accepts events that have already been flagged as handled.booleanReturns whether this filter accepts focus events.booleanReturns whether this filter accepts key pressed events.booleanReturns whether this filter accepts key released events.booleanReturns whether this filter accepts key typed events.booleanReturns whether this filter accepts mouse clicked events.booleanReturns whether this filter accepts mouse dragged events.booleanReturns whether this filter accepts mouse entered events.booleanReturns whether this filter accepts mouse exited events.booleanReturns whether this filter accepts mouse moved events.booleanReturns whether this filter accepts mouse pressed events.booleanReturns whether this filter accepts mouse released events.booleanReturns whether this filter accepts mouse wheel rotated events.booleanReturns whether this filter marks events as handled if they are accepted.voidFlags all mouse click events as disallowed, regardless of button configuration.voidConfigures filter so that no events will ever get accepted.voidsetAcceptClickCount(short aClickCount) Sets the number of clicks that an incoming event must have to be accepted.voidsetAcceptsAlreadyHandledEvents(boolean aBoolean) Sets whether already handled events should be accepted.voidsetAcceptsFocusEvents(boolean aBoolean) Sets whether this filter accepts focus events.voidsetAcceptsKeyPressed(boolean aBoolean) Sets whether this filter accepts key pressed events.voidsetAcceptsKeyReleased(boolean aBoolean) Sets whether this filter accepts key released events.voidsetAcceptsKeyTyped(boolean aBoolean) Sets whether this filter accepts key typed events.voidsetAcceptsMouseClicked(boolean aBoolean) Sets whether this filter accepts mouse clicked events.voidsetAcceptsMouseDragged(boolean aBoolean) Sets whether this filter accepts mouse dragged events.voidsetAcceptsMouseEntered(boolean aBoolean) Sets whether this filter accepts mouse entered events.voidsetAcceptsMouseExited(boolean aBoolean) Sets whether this filter accepts mouse exited events.voidsetAcceptsMouseMoved(boolean aBoolean) Sets whether this filter accepts mouse moved events.voidsetAcceptsMousePressed(boolean aBoolean) Sets whether this filter accepts mouse pressed events.voidsetAcceptsMouseReleased(boolean aBoolean) Sets whether this filter accepts mouse released events.voidsetAcceptsMouseWheelRotated(boolean aBoolean) Sets whether this filter accepts mouse wheel rotation events.voidsetAndMask(int aAndMask) Sets and mask used to filter events.voidsetMarksAcceptedEventsAsHandled(boolean aBoolean) Sets whether events will be marked as dirty once accepted.voidsetNotMask(int aNotMask) Sets not mask used to filter events.voidsetOrMask(int aOrMask) Sets or mask used to filter events.
-
Field Details
-
ALL_MODIFIERS_MASK
public static int ALL_MODIFIERS_MASKMask representing all possible modifiers.
-
-
Constructor Details
-
PInputEventFilter
public PInputEventFilter()Creates a PInputEventFilter that accepts everything. -
PInputEventFilter
public PInputEventFilter(int andMask) Creates a PInputEventFilter that will accept events if they have the given andMask.- Parameters:
andMask- exact pattern event modifiers must be to get accepted
-
PInputEventFilter
public PInputEventFilter(int andMask, int notMask) Creates a PInputEventFilter that will accept events if they have the given andMask and do not contain any of the bits in the notMask.- Parameters:
andMask- exact pattern event modifiers must be to get acceptednotMask- if any or these bits are on event is not accepted
-
-
Method Details
-
acceptsEvent
Returns true if the passed event is one that is accepted.- Parameters:
event- Event under considerationtype- The type of event encoded as the PInputEvent- Returns:
- true if event is accepted
-
acceptAllClickCounts
public void acceptAllClickCounts()Makes this filter accept all mouse click combinations. -
acceptAllEventTypes
public void acceptAllEventTypes()Makes the filter accept all event types. -
acceptEverything
public void acceptEverything()Makes this filter accept absolutely everything. -
getAcceptsKeyPressed
public boolean getAcceptsKeyPressed()Returns whether this filter accepts key pressed events.- Returns:
- true if filter accepts key pressed events
-
getAcceptsKeyReleased
public boolean getAcceptsKeyReleased()Returns whether this filter accepts key released events.- Returns:
- true if filter accepts key released events
-
getAcceptsKeyTyped
public boolean getAcceptsKeyTyped()Returns whether this filter accepts key typed events.- Returns:
- true if filter accepts key typed events
-
getAcceptsMouseClicked
public boolean getAcceptsMouseClicked()Returns whether this filter accepts mouse clicked events.- Returns:
- true if filter accepts mouse clicked events
-
getAcceptsMouseDragged
public boolean getAcceptsMouseDragged()Returns whether this filter accepts mouse dragged events.- Returns:
- true if filter accepts mouse dragged events
-
getAcceptsMouseEntered
public boolean getAcceptsMouseEntered()Returns whether this filter accepts mouse entered events.- Returns:
- true if filter accepts mouse entered events
-
getAcceptsMouseExited
public boolean getAcceptsMouseExited()Returns whether this filter accepts mouse exited events.- Returns:
- true if filter accepts mouse exited events
-
getAcceptsMouseMoved
public boolean getAcceptsMouseMoved()Returns whether this filter accepts mouse moved events.- Returns:
- true if filter accepts mouse moved events
-
getAcceptsMousePressed
public boolean getAcceptsMousePressed()Returns whether this filter accepts mouse pressed events.- Returns:
- true if filter accepts mouse pressed events
-
getAcceptsMouseReleased
public boolean getAcceptsMouseReleased()Returns whether this filter accepts mouse released events.- Returns:
- true if filter accepts mouse released events
-
getAcceptsMouseWheelRotated
public boolean getAcceptsMouseWheelRotated()Returns whether this filter accepts mouse wheel rotated events.- Returns:
- true if filter accepts mouse wheel rotated events
-
getAcceptsFocusEvents
public boolean getAcceptsFocusEvents()Returns whether this filter accepts focus events.- Returns:
- true if filter accepts focus events
-
getAcceptsAlreadyHandledEvents
public boolean getAcceptsAlreadyHandledEvents()Returns whether this filter accepts events that have already been flagged as handled.- Returns:
- true if filter accepts events that have already been flagged as handled
-
getMarksAcceptedEventsAsHandled
public boolean getMarksAcceptedEventsAsHandled()Returns whether this filter marks events as handled if they are accepted.- Returns:
- true if filter will mark events as filtered if they are accepted
-
rejectAllClickCounts
public void rejectAllClickCounts()Flags all mouse click events as disallowed, regardless of button configuration. -
rejectAllEventTypes
public void rejectAllEventTypes()Configures filter so that no events will ever get accepted. By itself not terribly useful, but it's a more restrictive starting point than acceptAllEvents(); -
setAcceptClickCount
public void setAcceptClickCount(short aClickCount) Sets the number of clicks that an incoming event must have to be accepted.- Parameters:
aClickCount- number clicks that an incoming event must have to be accepted
-
setAcceptsKeyPressed
public void setAcceptsKeyPressed(boolean aBoolean) Sets whether this filter accepts key pressed events.- Parameters:
aBoolean- whether filter should accept key pressed events
-
setAcceptsKeyReleased
public void setAcceptsKeyReleased(boolean aBoolean) Sets whether this filter accepts key released events.- Parameters:
aBoolean- whether filter should accept key released events
-
setAcceptsKeyTyped
public void setAcceptsKeyTyped(boolean aBoolean) Sets whether this filter accepts key typed events.- Parameters:
aBoolean- whether filter should accept key typed events
-
setAcceptsMouseClicked
public void setAcceptsMouseClicked(boolean aBoolean) Sets whether this filter accepts mouse clicked events.- Parameters:
aBoolean- whether filter should accept mouse clicked events
-
setAcceptsMouseDragged
public void setAcceptsMouseDragged(boolean aBoolean) Sets whether this filter accepts mouse dragged events.- Parameters:
aBoolean- whether filter should accept mouse dragged events
-
setAcceptsMouseEntered
public void setAcceptsMouseEntered(boolean aBoolean) Sets whether this filter accepts mouse entered events.- Parameters:
aBoolean- whether filter should accept mouse entered events
-
setAcceptsMouseExited
public void setAcceptsMouseExited(boolean aBoolean) Sets whether this filter accepts mouse exited events.- Parameters:
aBoolean- whether filter should accept mouse exited events
-
setAcceptsMouseMoved
public void setAcceptsMouseMoved(boolean aBoolean) Sets whether this filter accepts mouse moved events.- Parameters:
aBoolean- whether filter should accept mouse moved events
-
setAcceptsMousePressed
public void setAcceptsMousePressed(boolean aBoolean) Sets whether this filter accepts mouse pressed events.- Parameters:
aBoolean- whether filter should accept mouse pressed events
-
setAcceptsMouseReleased
public void setAcceptsMouseReleased(boolean aBoolean) Sets whether this filter accepts mouse released events.- Parameters:
aBoolean- whether filter should accept mouse released events
-
setAcceptsMouseWheelRotated
public void setAcceptsMouseWheelRotated(boolean aBoolean) Sets whether this filter accepts mouse wheel rotation events.- Parameters:
aBoolean- whether filter should accept mouse wheel rotated events
-
setAcceptsFocusEvents
public void setAcceptsFocusEvents(boolean aBoolean) Sets whether this filter accepts focus events.- Parameters:
aBoolean- whether filter should accept focus events
-
setAndMask
public void setAndMask(int aAndMask) Sets and mask used to filter events. All bits of the andMask must be 1s for the event to be accepted.- Parameters:
aAndMask- the and mask to use for filtering events
-
setAcceptsAlreadyHandledEvents
public void setAcceptsAlreadyHandledEvents(boolean aBoolean) Sets whether already handled events should be accepted.- Parameters:
aBoolean- whether already handled events should be accepted
-
setMarksAcceptedEventsAsHandled
public void setMarksAcceptedEventsAsHandled(boolean aBoolean) Sets whether events will be marked as dirty once accepted.- Parameters:
aBoolean- whether events will be marked as dirty once accepted
-
setNotMask
public void setNotMask(int aNotMask) Sets not mask used to filter events. If any of the not bits are enabled, then the event is not accepted.- Parameters:
aNotMask- the not mask to use for filtering events
-
setOrMask
public void setOrMask(int aOrMask) Sets or mask used to filter events. If any of the or bits are enabled, then the event is accepted.- Parameters:
aOrMask- the or mask to use for filtering events
-