Package com.badlogic.gdx.scenes.scene2d
Class InputEvent
- java.lang.Object
-
- com.badlogic.gdx.scenes.scene2d.Event
-
- com.badlogic.gdx.scenes.scene2d.InputEvent
-
- All Implemented Interfaces:
Pool.Poolable
public class InputEvent extends Event
Event for actor input: touch, mouse, touch/mouse actor enter/exit, mouse scroll, and keyboard events.- See Also:
InputListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInputEvent.TypeTypes of low-level input events supported by scene2d.
-
Constructor Summary
Constructors Constructor Description InputEvent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetButton()The index for the mouse button pressed.chargetCharacter()The character for the key that was typed.intgetKeyCode()The key code of the key that was pressed.intgetPointer()The pointer index for the event.ActorgetRelatedActor()The actor related to the event.floatgetScrollAmountX()The amount the mouse was scrolled horizontally.floatgetScrollAmountY()The amount the mouse was scrolled vertically.floatgetStageX()The stage x coordinate where the event occurred.floatgetStageY()The stage x coordinate where the event occurred.booleangetTouchFocus()If false,InputListener.handle(Event)will not add the listener to the stage's touch focus when a touch down event is handled.InputEvent.TypegetType()The type of input event.booleanisTouchFocusCancel()Returns true if this event is a touchUp triggered byStage.cancelTouchFocus().voidreset()Resets the object for reuse.voidsetButton(int button)voidsetCharacter(char character)voidsetKeyCode(int keyCode)voidsetPointer(int pointer)voidsetRelatedActor(Actor relatedActor)voidsetScrollAmountX(float scrollAmount)voidsetScrollAmountY(float scrollAmount)voidsetStageX(float stageX)voidsetStageY(float stageY)voidsetTouchFocus(boolean touchFocus)voidsetType(InputEvent.Type type)Vector2toCoordinates(Actor actor, Vector2 actorCoords)Sets actorCoords to this event's coordinates relative to the specified actor.java.lang.StringtoString()-
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Event
cancel, getBubbles, getListenerActor, getStage, getTarget, handle, isCancelled, isCapture, isHandled, isStopped, setBubbles, setCapture, setListenerActor, setStage, setTarget, stop
-
-
-
-
Method Detail
-
reset
public void reset()
Description copied from interface:Pool.PoolableResets the object for reuse. Object references should be nulled and fields may be set to default values.- Specified by:
resetin interfacePool.Poolable- Overrides:
resetin classEvent
-
getStageX
public float getStageX()
The stage x coordinate where the event occurred. Valid for: touchDown, touchDragged, touchUp, mouseMoved, enter, and exit.
-
setStageX
public void setStageX(float stageX)
-
getStageY
public float getStageY()
The stage x coordinate where the event occurred. Valid for: touchDown, touchDragged, touchUp, mouseMoved, enter, and exit.
-
setStageY
public void setStageY(float stageY)
-
getType
public InputEvent.Type getType()
The type of input event.
-
setType
public void setType(InputEvent.Type type)
-
getPointer
public int getPointer()
The pointer index for the event. The first touch is index 0, second touch is index 1, etc. Always -1 on desktop. Valid for: touchDown, touchDragged, touchUp, enter, and exit.
-
setPointer
public void setPointer(int pointer)
-
getButton
public int getButton()
The index for the mouse button pressed. Always 0 on Android. Valid for: touchDown and touchUp.- See Also:
Input.Buttons
-
setButton
public void setButton(int button)
-
getKeyCode
public int getKeyCode()
The key code of the key that was pressed. Valid for: keyDown and keyUp.
-
setKeyCode
public void setKeyCode(int keyCode)
-
getCharacter
public char getCharacter()
The character for the key that was typed. Valid for: keyTyped.
-
setCharacter
public void setCharacter(char character)
-
getScrollAmountX
public float getScrollAmountX()
The amount the mouse was scrolled horizontally. Valid for: scrolled.
-
getScrollAmountY
public float getScrollAmountY()
The amount the mouse was scrolled vertically. Valid for: scrolled.
-
setScrollAmountX
public void setScrollAmountX(float scrollAmount)
-
setScrollAmountY
public void setScrollAmountY(float scrollAmount)
-
getRelatedActor
@Null public Actor getRelatedActor()
The actor related to the event. Valid for: enter and exit. For enter, this is the actor being exited, or null. For exit, this is the actor being entered, or null.
-
setRelatedActor
public void setRelatedActor(@Null Actor relatedActor)
- Parameters:
relatedActor- May be null.
-
toCoordinates
public Vector2 toCoordinates(Actor actor, Vector2 actorCoords)
Sets actorCoords to this event's coordinates relative to the specified actor.- Parameters:
actorCoords- Output for resulting coordinates.
-
isTouchFocusCancel
public boolean isTouchFocusCancel()
Returns true if this event is a touchUp triggered byStage.cancelTouchFocus().
-
getTouchFocus
public boolean getTouchFocus()
If false,InputListener.handle(Event)will not add the listener to the stage's touch focus when a touch down event is handled. Default is true.
-
setTouchFocus
public void setTouchFocus(boolean touchFocus)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-