|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.InputListener
com.badlogic.gdx.scenes.scene2d.utils.ClickListener
public class ClickListener
Detects mouse over, mouse or finger touch presses, and clicks on an actor. A touch must go down over the actor and is
considered pressed as long as it is over the actor or within the tap square
. This behavior
makes it easier to press buttons on a touch interface when the initial touch happens near the edge of the actor. Double clicks
can be detected using getTapCount()
. Any touch (not just the first) will trigger this listener. While pressed, other
touch downs are ignored.
Constructor Summary | |
---|---|
ClickListener()
|
|
ClickListener(int button)
|
Method Summary | |
---|---|
void |
cancel()
If a touch down is being monitored, the drag and touch up events are ignored until the next touch up. |
void |
clicked(InputEvent event,
float x,
float y)
|
void |
drag(InputEvent event,
float x,
float y,
int pointer)
|
void |
dragStart(InputEvent event,
float x,
float y,
int pointer)
|
void |
dragStop(InputEvent event,
float x,
float y,
int pointer)
|
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. |
int |
getButton()
|
int |
getTapCount()
Returns the number of taps within the tap count interval for the most recent click event. |
float |
getTapSquareSize()
|
float |
getTouchDownX()
|
float |
getTouchDownY()
|
boolean |
inTapSquare(float x,
float y)
|
void |
invalidateTapSquare()
The tap square will not longer be used for the current touch. |
boolean |
isOver()
Returns true if the mouse or touch is over the actor or pressed and within the tap square. |
boolean |
isOver(Actor actor,
float x,
float y)
Returns true if the specified position is over the specified actor or within the tap square. |
boolean |
isPressed()
Returns true if a touch is over the actor or within the tap square. |
void |
setButton(int button)
Sets the button to listen for, all other buttons are ignored. |
void |
setTapCountInterval(float tapCountInterval)
|
void |
setTapSquareSize(float halfTapSquareSize)
|
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. |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.InputListener |
---|
handle, keyDown, keyTyped, keyUp, mouseMoved, scrolled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClickListener()
public ClickListener(int button)
Method Detail |
---|
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
InputListener
handled
.
touchDown
in class InputListener
InputEvent
public void touchDragged(InputEvent event, float x, float y, int pointer)
InputListener
handled
.
touchDragged
in class InputListener
InputEvent
public void touchUp(InputEvent event, float x, float y, int pointer, int button)
InputListener
handled
.
touchUp
in class InputListener
InputEvent
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor)
InputListener
enter
in class InputListener
InputEvent
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
InputListener
exit
in class InputListener
InputEvent
public void cancel()
public void clicked(InputEvent event, float x, float y)
public void dragStart(InputEvent event, float x, float y, int pointer)
public void drag(InputEvent event, float x, float y, int pointer)
public void dragStop(InputEvent event, float x, float y, int pointer)
public boolean isOver(Actor actor, float x, float y)
public boolean inTapSquare(float x, float y)
public void invalidateTapSquare()
public boolean isPressed()
public boolean isOver()
public void setTapSquareSize(float halfTapSquareSize)
public float getTapSquareSize()
public void setTapCountInterval(float tapCountInterval)
tapCountInterval
- time in seconds that must pass for two touch down/up sequences to be detected as consecutive taps.public int getTapCount()
public float getTouchDownX()
public float getTouchDownY()
public int getButton()
public void setButton(int button)
Input.Buttons.LEFT
. Use -1 for any button.
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |