Package com.prineside.tdi2.scene2d
Class InputListener
java.lang.Object
com.prineside.tdi2.scene2d.InputListener
- All Implemented Interfaces:
EventListener
- Direct Known Subclasses:
ClickListener
,CursorGraphicsManager.CustomCursorActorListener
,DragListener
,InputListenerExtended
,InputVoid
,Tooltip
EventListener for low-level input events. Unpacks
InputEvent
s 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:
actor.addListener(new InputListener() { public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { Gdx.app.log("Example", "touch started at (" + x + ", " + y + ")"); return false; } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { Gdx.app.log("Example", "touch done at (" + x + ", " + y + ")"); } });
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
enter
(InputEvent event, float x, float y, int pointer, Actor fromActor) Called any time the mouse cursor or a finger touch is moved over an actor.void
exit
(InputEvent event, float x, float y, int pointer, Actor toActor) Called any time the mouse cursor or a finger touch is moved out of an actor.boolean
Try to handle the given event, if it is anInputEvent
.boolean
keyDown
(InputEvent event, int keycode) Called when a key goes down.boolean
keyTyped
(InputEvent event, char character) Called when a key is typed.boolean
keyUp
(InputEvent event, int 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, int button) Called when a mouse button or a finger touch goes down on the actor.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, int 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.
-
Constructor Details
-
InputListener
public InputListener()
-
-
Method Details
-
handle
Try to handle the given event, if it is anInputEvent
.If the input event is of type
InputEvent.Type.touchDown
andInputEvent.getTouchFocus()
is true andtouchDown(InputEvent, float, float, int, int)
returns true (indicating the event was handled) then this listener is added to the stage'stouch focus
so it will receive all touch dragged events until the next touch up event.- Specified by:
handle
in interfaceEventListener
- Returns:
- true if the event should be considered
handled
by scene2d.
-
touchDown
Called when a mouse button or a finger touch goes down on the actor. If true is returned, this listener will havetouch focus
, so it will receive all touchDragged and touchUp events, even those not over this actor, until touchUp is received. Also when true is returned, the event ishandled
.- See Also:
-
touchUp
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 alwayshandled
.- See Also:
-
touchDragged
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 alwayshandled
.- See Also:
-
mouseMoved
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 ishandled
.- See Also:
-
enter
Called any time the mouse cursor or a finger touch is moved over an actor. 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
Called any time the mouse cursor or a finger touch is moved out of an actor. 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
Called when the mouse wheel has been scrolled. When true is returned, the event ishandled
. -
keyDown
Called when a key goes down. When true is returned, the event ishandled
. -
keyUp
Called when a key goes up. When true is returned, the event ishandled
. -
keyTyped
Called when a key is typed. When true is returned, the event ishandled
.- Parameters:
character
- May be 0 for key typed events that don't map to a character (ctrl, shift, etc).
-