Package com.badlogic.gdx.scenes.scene2d

Examples of com.badlogic.gdx.scenes.scene2d.InputListener


      setOverscroll(false, false);
      setFadeScrollBars(false);

      list = new List(new Object[0], style.listStyle);
      setWidget(list);
      list.addListener(new InputListener() {
        public boolean mouseMoved (InputEvent event, float x, float y) {
          list.setSelectedIndex(Math.min(items.length - 1, (int)((list.getHeight() - y) / list.getItemHeight())));
          return true;
        }
      });

      addListener(new InputListener() {
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
          if (event.getTarget() == list) return true;
          hideList();
          return false;
        }
View Full Code Here


    setTitle(title);

    buttonTable = new Table();
    addActor(buttonTable);

    addCaptureListener(new InputListener() {
      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        toFront();
        return false;
      }
    });
    addListener(new InputListener() {
      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        if (button == 0) {
          dragging = isMovable && getHeight() - y <= getPadTop() && y < getHeight() && x > 0 && x < getWidth();
          dragOffset.set(x, y);
        }
View Full Code Here

    this.style = style;
    setWidget(widget);
    setWidth(150);
    setHeight(150);

    addCaptureListener(new InputListener() {
      private float handlePosition;

      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        if (draggingPointer != -1) return false;
        if (pointer == 0 && button != 0) return false;
        getStage().setScrollFocus(ScrollPane.this);

        if (!flickScroll) resetFade();

        if (fadeAlpha == 0) return false;

        if (scrollX && hScrollBounds.contains(x, y)) {
          event.stop();
          resetFade();
          if (hKnobBounds.contains(x, y)) {
            lastPoint.set(x, y);
            handlePosition = hKnobBounds.x;
            touchScrollH = true;
            draggingPointer = pointer;
            return true;
          }
          setScrollX(amountX + areaWidth * (x < hKnobBounds.x ? -1 : 1));
          return true;
        }
        if (scrollY && vScrollBounds.contains(x, y)) {
          event.stop();
          resetFade();
          if (vKnobBounds.contains(x, y)) {
            lastPoint.set(x, y);
            handlePosition = vKnobBounds.y;
            touchScrollV = true;
            draggingPointer = pointer;
            return true;
          }
          setScrollY(amountY + areaHeight * (y < vKnobBounds.y ? 1 : -1));
          return true;
        }
        return false;
      }

      public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
        if (pointer != draggingPointer) return;
        cancel();
      }

      public void touchDragged (InputEvent event, float x, float y, int pointer) {
        if (pointer != draggingPointer) return;
        if (touchScrollH) {
          float delta = x - lastPoint.x;
          float scrollH = handlePosition + delta;
          handlePosition = scrollH;
          scrollH = Math.max(hScrollBounds.x, scrollH);
          scrollH = Math.min(hScrollBounds.x + hScrollBounds.width - hKnobBounds.width, scrollH);
          float total = hScrollBounds.width - hKnobBounds.width;
          if (total != 0) setScrollPercentX((scrollH - hScrollBounds.x) / total);
          lastPoint.set(x, y);
        } else if (touchScrollV) {
          float delta = y - lastPoint.y;
          float scrollV = handlePosition + delta;
          handlePosition = scrollV;
          scrollV = Math.max(vScrollBounds.y, scrollV);
          scrollV = Math.min(vScrollBounds.y + vScrollBounds.height - vKnobBounds.height, scrollV);
          float total = vScrollBounds.height - vKnobBounds.height;
          if (total != 0) setScrollPercentY(1 - ((scrollV - vScrollBounds.y) / total));
          lastPoint.set(x, y);
        }
      }

      public boolean mouseMoved (InputEvent event, float x, float y) {
        if (!flickScroll) resetFade();
        return false;
      }
    });

    flickScrollListener = new ActorGestureListener() {
      public void pan (InputEvent event, float x, float y, float deltaX, float deltaY) {
        resetFade();
        amountX -= deltaX;
        amountY += deltaY;
        clamp();
        cancelTouchFocusedChild(event);
      }

      public void fling (InputEvent event, float x, float y, int button) {
        if (Math.abs(x) > 150) {
          flingTimer = flingTime;
          velocityX = x;
          cancelTouchFocusedChild(event);
        }
        if (Math.abs(y) > 150) {
          flingTimer = flingTime;
          velocityY = -y;
          cancelTouchFocusedChild(event);
        }
      }

      public boolean handle (Event event) {
        if (super.handle(event)) {
          if (((InputEvent)event).getType() == InputEvent.Type.touchDown) flingTimer = 0;
          return true;
        }
        return false;
      }
    };
    addListener(flickScrollListener);

    addListener(new InputListener() {
      public boolean scrolled (InputEvent event, float x, float y, int amount) {
        resetFade();
        if (scrollY)
          setScrollY(amountY + getMouseWheelY() * amount);
        else if (scrollX) //
View Full Code Here

      setOverscroll(false, false);
      setFadeScrollBars(false);

      list = new List(style.listStyle);
      setWidget(list);
      list.addListener(new InputListener() {
        public boolean mouseMoved (InputEvent event, float x, float y) {
          list.setSelectedIndex(Math.min(items.size - 1, (int)((list.getHeight() - y) / list.getItemHeight())));
          return true;
        }
      });

      addListener(new InputListener() {
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
          if (event.getTarget() == list) return true;
          setSelected(selected); // Revert.
          hideList();
          return false;
View Full Code Here

    if (style == null) throw new IllegalArgumentException("style cannot be null.");
    this.style = style;
    setWidget(widget);
    setSize(150, 150);

    addCaptureListener(new InputListener() {
      private float handlePosition;

      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        if (draggingPointer != -1) return false;
        if (pointer == 0 && button != 0) return false;
        getStage().setScrollFocus(ScrollPane.this);

        if (!flickScroll) resetFade();

        if (fadeAlpha == 0) return false;

        if (scrollX && hScrollBounds.contains(x, y)) {
          event.stop();
          resetFade();
          if (hKnobBounds.contains(x, y)) {
            lastPoint.set(x, y);
            handlePosition = hKnobBounds.x;
            touchScrollH = true;
            draggingPointer = pointer;
            return true;
          }
          setScrollX(amountX + areaWidth * (x < hKnobBounds.x ? -1 : 1));
          return true;
        }
        if (scrollY && vScrollBounds.contains(x, y)) {
          event.stop();
          resetFade();
          if (vKnobBounds.contains(x, y)) {
            lastPoint.set(x, y);
            handlePosition = vKnobBounds.y;
            touchScrollV = true;
            draggingPointer = pointer;
            return true;
          }
          setScrollY(amountY + areaHeight * (y < vKnobBounds.y ? 1 : -1));
          return true;
        }
        return false;
      }

      public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
        if (pointer != draggingPointer) return;
        cancel();
      }

      public void touchDragged (InputEvent event, float x, float y, int pointer) {
        if (pointer != draggingPointer) return;
        if (touchScrollH) {
          float delta = x - lastPoint.x;
          float scrollH = handlePosition + delta;
          handlePosition = scrollH;
          scrollH = Math.max(hScrollBounds.x, scrollH);
          scrollH = Math.min(hScrollBounds.x + hScrollBounds.width - hKnobBounds.width, scrollH);
          float total = hScrollBounds.width - hKnobBounds.width;
          if (total != 0) setScrollPercentX((scrollH - hScrollBounds.x) / total);
          lastPoint.set(x, y);
        } else if (touchScrollV) {
          float delta = y - lastPoint.y;
          float scrollV = handlePosition + delta;
          handlePosition = scrollV;
          scrollV = Math.max(vScrollBounds.y, scrollV);
          scrollV = Math.min(vScrollBounds.y + vScrollBounds.height - vKnobBounds.height, scrollV);
          float total = vScrollBounds.height - vKnobBounds.height;
          if (total != 0) setScrollPercentY(1 - ((scrollV - vScrollBounds.y) / total));
          lastPoint.set(x, y);
        }
      }

      public boolean mouseMoved (InputEvent event, float x, float y) {
        if (!flickScroll) resetFade();
        return false;
      }
    });

    flickScrollListener = new ActorGestureListener() {
      public void pan (InputEvent event, float x, float y, float deltaX, float deltaY) {
        resetFade();
        amountX -= deltaX;
        amountY += deltaY;
        clamp();
        cancelTouchFocusedChild(event);
      }

      public void fling (InputEvent event, float x, float y, int button) {
        if (Math.abs(x) > 150) {
          flingTimer = flingTime;
          velocityX = x;
          cancelTouchFocusedChild(event);
        }
        if (Math.abs(y) > 150) {
          flingTimer = flingTime;
          velocityY = -y;
          cancelTouchFocusedChild(event);
        }
      }

      public boolean handle (Event event) {
        if (super.handle(event)) {
          if (((InputEvent)event).getType() == InputEvent.Type.touchDown) flingTimer = 0;
          return true;
        }
        return false;
      }
    };
    addListener(flickScrollListener);

    addListener(new InputListener() {
      public boolean scrolled (InputEvent event, float x, float y, int amount) {
        resetFade();
        if (scrollY)
          setScrollY(amountY + getMouseWheelY() * amount);
        else if (scrollX) //
View Full Code Here

    knobPosition.set(getWidth() / 2f, getHeight() / 2f);

    setStyle(style);
    setSize(getPrefWidth(), getPrefHeight());

    addListener(new InputListener() {
      @Override
      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        if (touched) return false;
        touched = true;
        calculatePositionAndValue(x, y, false);
View Full Code Here

  }

  /** If this key is pressed, {@link #result(Object)} is called with the specified object.
   * @see Keys */
  public Dialog key (final int keycode, final Object object) {
    addListener(new InputListener() {
      public boolean keyDown (InputEvent event, int keycode2) {
        if (keycode == keycode2) {
          result(object);
          if (!cancelHide) hide();
          cancelHide = false;
View Full Code Here

    selection.setRequired(true);

    setStyle(style);
    setSize(getPrefWidth(), getPrefHeight());

    addListener(new InputListener() {
      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        if (pointer == 0 && button != 0) return false;
        if (selection.isDisabled()) return false;
        List.this.touchDown(y);
        return true;
View Full Code Here

      setOverscroll(false, false);
      setFadeScrollBars(false);

      list = new List(style.listStyle);
      setWidget(list);
      list.addListener(new InputListener() {
        public boolean mouseMoved (InputEvent event, float x, float y) {
          list.setSelectedIndex(Math.min(items.size - 1, (int)((list.getHeight() - y) / list.getItemHeight())));
          return true;
        }
      });

      addListener(new InputListener() {
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
          if (event.getTarget() == list) return true;
          setSelected(selected); // Revert.
          hideList();
          return false;
View Full Code Here

    setTitle(title);

    buttonTable = new Table();
    addActor(buttonTable);

    addCaptureListener(new InputListener() {
      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        toFront();
        return false;
      }
    });
    addListener(new InputListener() {
      int edge;
      float startX, startY, lastX, lastY;

      public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
        if (button == 0) {
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.scenes.scene2d.InputListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.