Class InputListener

java.lang.Object
arc.scene.event.InputListener
All Implemented Interfaces:
EventListener
Direct Known Subclasses:
ClickListener, DragListener, MapObjectivesCanvas.ObjectiveTilemap.ObjectiveTile.Mover, Tooltip

public class InputListener extends Object implements EventListener
EventListener for low-level input events. Unpacks InputEvents and calls the appropriate method. By default the methods here do nothing with the event. Users are expected to override the methods they are interested in, like this:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    enter(InputEvent event, float x, float y, int pointer, Element fromActor)
    Called any time the mouse cursor or a finger touch is moved over an element.
    void
    exit(InputEvent event, float x, float y, int pointer, Element toActor)
    Called any time the mouse cursor or a finger touch is moved out of an element.
    boolean
    Try to handle the given event, if it is applicable.
    boolean
    keyDown(InputEvent event, KeyCode keycode)
    Called when a key goes down.
    boolean
    keyTyped(InputEvent event, char character)
    Called when a key is typed.
    boolean
    keyUp(InputEvent event, KeyCode keycode)
    Called when a key goes up.
    boolean
    mouseMoved(InputEvent event, float x, float y)
    Called any time the mouse is moved when a button is not down.
    boolean
    scrolled(InputEvent event, float x, float y, float amountX, float amountY)
    Called when the mouse wheel has been scrolled.
    boolean
    touchDown(InputEvent event, float x, float y, int pointer, KeyCode button)
    Called when a mouse button or a finger touch goes down on the element.
    void
    touchDragged(InputEvent event, float x, float y, int pointer)
    Called when a mouse button or a finger touch is moved anywhere, but only if touchDown previously returned true for the mouse button or touch.
    void
    touchUp(InputEvent event, float x, float y, int pointer, KeyCode button)
    Called when a mouse button or a finger touch goes up anywhere, but only if touchDown previously returned true for the mouse button or touch.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InputListener

      public InputListener()
  • Method Details

    • handle

      public boolean handle(SceneEvent e)
      Description copied from interface: EventListener
      Try to handle the given event, if it is applicable.
      Specified by:
      handle in interface EventListener
      Returns:
      true if the event should be considered handled by scene2d.
    • touchDown

      public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button)
      Called when a mouse button or a finger touch goes down on the element. If true is returned, this listener will receive all touchDragged and touchUp events, even those not over this element, until touchUp is received. Also when true is returned, the event is handled.
      See Also:
    • touchUp

      public void touchUp(InputEvent event, float x, float y, int pointer, KeyCode button)
      Called when a mouse button or a finger touch goes up anywhere, but only if touchDown previously returned true for the mouse button or touch. The touchUp event is always handled.
      See Also:
    • touchDragged

      public void touchDragged(InputEvent event, float x, float y, int pointer)
      Called when a mouse button or a finger touch is moved anywhere, but only if touchDown previously returned true for the mouse button or touch. The touchDragged event is always handled.
      See Also:
    • mouseMoved

      public boolean mouseMoved(InputEvent event, float x, float y)
      Called any time the mouse is moved when a button is not down. This event only occurs on the desktop. When true is returned, the event is handled.
      See Also:
    • enter

      public void enter(InputEvent event, float x, float y, int pointer, Element fromActor)
      Called any time the mouse cursor or a finger touch is moved over an element. On the desktop, this event occurs even when no mouse buttons are pressed (pointer will be -1).
      Parameters:
      fromActor - May be null.
      See Also:
    • exit

      public void exit(InputEvent event, float x, float y, int pointer, Element toActor)
      Called any time the mouse cursor or a finger touch is moved out of an element. On the desktop, this event occurs even when no mouse buttons are pressed (pointer will be -1).
      Parameters:
      toActor - May be null.
      See Also:
    • scrolled

      public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY)
      Called when the mouse wheel has been scrolled. When true is returned, the event is handled.
    • keyDown

      public boolean keyDown(InputEvent event, KeyCode keycode)
      Called when a key goes down. When true is returned, the event is handled.
    • keyUp

      public boolean keyUp(InputEvent event, KeyCode keycode)
      Called when a key goes up. When true is returned, the event is handled.
    • keyTyped

      public boolean keyTyped(InputEvent event, char character)
      Called when a key is typed. When true is returned, the event is handled.