public class InputListener extends java.lang.Object implements EventListener
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:
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 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)
EventListenerhandle in interface EventListenerhandled by scene2d.public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
handled.InputEventpublic void touchUp(InputEvent event, float x, float y, int pointer, int button)
handled.InputEventpublic void touchDragged(InputEvent event, float x, float y, int pointer)
handled.InputEventpublic boolean mouseMoved(InputEvent event, float x, float y)
handled.InputEventpublic void enter(InputEvent event, float x, float y, int pointer, Actor fromActor)
fromActor - May be null.InputEventpublic void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
toActor - May be null.InputEventpublic 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.character - May be 0 for key typed events that don't map to a character (ctrl, shift, etc).