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 + ")");
}
});
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | enter(InputEvent event, float x, float y, int pointer, Actor
May be null. fromActor)Called any time the mouse cursor or a finger touch is moved over an actor. |
| public void | exit(InputEvent event, float x, float y, int pointer, Actor
May be null. toActor)Called any time the mouse cursor or a finger touch is moved out of an actor. |
| public boolean | handle(Event e)
Implements com. Try to handle the given event, if it is an |
| public boolean | |
| public boolean | keyTyped(InputEvent event, char
May be 0 for key typed events that don't map to a character (ctrl, shift, etc). character)Called when a key is typed. |
| public boolean | |
| public boolean | mouseMoved(InputEvent event, float x, float y)
Called any time the mouse is moved when a button is not down. |
| public boolean | scrolled(InputEvent event, float x, float y, float amountX, float amountY)
Called when the mouse wheel has been scrolled. |
| public 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. |
| 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. |
| public 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. |
| tmpCoords | back to summary |
|---|---|
| private static final Vector2 tmpCoords | |
| InputListener | back to summary |
|---|---|
| public InputListener() | |
| enter | back to summary |
|---|---|
| public 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. On the desktop, this event occurs even when no mouse buttons are pressed (pointer will be -1).
| |
| exit | back to summary |
|---|---|
| public 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. On the desktop, this event occurs even when no mouse buttons are pressed (pointer will be -1).
| |
| handle | back to summary |
|---|---|
| public boolean handle(Event e) Implements com. Try to handle the given event, if it is an
If the input event is of type | |
| keyDown | back to summary |
|---|---|
| public boolean keyDown(InputEvent event, int keycode) Called when a key goes down. When true is returned, the event is | |
| keyTyped | back to summary |
|---|---|
| public boolean keyTyped(InputEvent event, char character) Called when a key is typed. When true is returned, the event is
| |
| keyUp | back to summary |
|---|---|
| public boolean keyUp(InputEvent event, int keycode) Called when a key goes up. When true is returned, the event is | |
| mouseMoved | back to summary |
|---|---|
| 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
| |
| scrolled | back to summary |
|---|---|
| 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 | |
| touchDown | back to summary |
|---|---|
| public 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. If true is returned, this listener will have
| |
| touchDragged | back to summary |
|---|---|
| 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
| |
| touchUp | back to summary |
|---|---|
| public 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. The touchUp event is always
| |