Java Code Examples for com.badlogic.gdx.scenes.scene2d.InputEvent#setType()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.InputEvent#setType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Scene2dUtils.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
public static void simulateClickGlobal(Actor actor, int button, int pointer, float stageX, float stageY) {
    InputEvent event = Pools.obtain(InputEvent.class);
    event.setStage(actor.getStage());
    event.setRelatedActor(actor);
    event.setTarget(actor);
    event.setStageX(stageX);
    event.setStageY(stageY);
    event.setButton(button);
    event.setPointer(pointer);

    event.setType(InputEvent.Type.touchDown);
    actor.notify(event, false);
    event.setType(InputEvent.Type.touchUp);
    actor.notify(event, false);

    Pools.free(event);
}
 
Example 2
Source File: ControllerMenuStage.java    From gdx-controllerutils with Apache License 2.0 6 votes vote down vote up
protected boolean fireEventOnActor(Actor actor, InputEvent.Type type, int pointer, Actor related) {
    if (actor == null || !isActorFocusable(actor) || !isActorHittable(actor))
        return false;

    InputEvent event = Pools.obtain(InputEvent.class);
    event.setType(type);
    event.setStage(this);
    event.setRelatedActor(related);
    event.setPointer(pointer);
    event.setButton(pointer);
    event.setStageX(0);
    event.setStageY(0);

    actor.fire(event);

    boolean handled = event.isHandled();
    Pools.free(event);
    return handled;
}
 
Example 3
Source File: Scene2dUtils.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
public static void simulateClickGlobal(Actor actor, int button, int pointer, float stageX, float stageY) {
    InputEvent event = Pools.obtain(InputEvent.class);
    event.setStage(actor.getStage());
    event.setRelatedActor(actor);
    event.setTarget(actor);
    event.setStageX(stageX);
    event.setStageY(stageY);
    event.setButton(button);
    event.setPointer(pointer);

    event.setType(InputEvent.Type.touchDown);
    actor.notify(event, false);
    event.setType(InputEvent.Type.touchUp);
    actor.notify(event, false);

    Pools.free(event);
}
 
Example 4
Source File: EventUtils.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public static boolean click(Button button) {
  if (button.isDisabled()) return false;
  InputEvent event = Pools.obtain(InputEvent.class);
  event.setType(InputEvent.Type.touchDown);
  event.setStage(button.getStage());
  event.setStageX(0);
  event.setStageY(0);
  event.setPointer(0);
  event.setButton(Input.Buttons.LEFT);
  event.setListenerActor(button);
  button.fire(event);

  event.setType(InputEvent.Type.touchUp);
  button.fire(event);
  Pools.free(event);
  return true;
}