Class PInputEventFilter

java.lang.Object
edu.umd.cs.piccolo.event.PInputEventFilter

public class PInputEventFilter extends Object
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 Details

    • ALL_MODIFIERS_MASK

      public static int ALL_MODIFIERS_MASK
      Mask 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 accepted
      notMask - if any or these bits are on event is not accepted
  • Method Details

    • acceptsEvent

      public boolean acceptsEvent(PInputEvent event, int type)
      Returns true if the passed event is one that is accepted.
      Parameters:
      event - Event under consideration
      type - 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