public class InputListener extends Object implements EventListener
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 + ")"); } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { Gdx.app.log("Example", "touch done at (" + x + ", " + y + ")"); } });
Constructor and Description |
---|
InputListener() |
Modifier and Type | Method and Description |
---|---|
void |
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 |
handle(Event e)
Try to handle the given event, if it is applicable.
|
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,
int amount)
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.
|
public boolean handle(Event e)
EventListener
handle
in interface EventListener
handled
by scene2d.public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
handled
.InputEvent
public void touchUp(InputEvent event, float x, float y, int pointer, int button)
handled
.InputEvent
public void touchDragged(InputEvent event, float x, float y, int pointer)
handled
.InputEvent
public boolean mouseMoved(InputEvent event, float x, float y)
handled
.InputEvent
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor)
fromActor
- May be null.InputEvent
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
toActor
- May be null.InputEvent
public boolean scrolled(InputEvent event, float x, float y, int amount)
handled
.public boolean keyDown(InputEvent event, int keycode)
handled
.public boolean keyUp(InputEvent event, int keycode)
handled
.public boolean keyTyped(InputEvent event, char character)
handled
.Copyright © 2015. All rights reserved.