Example usage for com.badlogic.gdx.scenes.scene2d.ui ScrollPane getScrollY

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui ScrollPane getScrollY

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui ScrollPane getScrollY.

Prototype

public float getScrollY() 

Source Link

Document

Returns the y scroll position in pixels, where 0 is the top of the scroll pane.

Usage

From source file:com.ridiculousRPG.ui.ActorsOnStageService.java

License:Apache License

@Override
public boolean scrolled(int amount) {
    if (getScrollFocus() instanceof ScrollPane) {
        ScrollPane s = (ScrollPane) getScrollFocus();
        s.setScrollY(s.getScrollY() + SCROLL_PIXEL_AMOUNT * amount);
        return true;
    }//from  www  .  j  a  v a 2s. co  m
    return false;
}

From source file:com.ridiculousRPG.ui.ActorsOnStageService.java

License:Apache License

@Override
public boolean keyDown(int keycode) {
    // unfocus if actor is removed
    if (focusedActor != null && !ActorFocusUtil.isActorOnStage(focusedActor, getRoot())) {
        setKeyboardFocus(null);//  w ww.jav  a  2 s  .c o m
        focusedActor = null;
        awaitingKeyUp = false;
    }
    // consume tab key down
    if (keycode == Keys.TAB) {
        if (Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT)) {
            return checkScroll(ActorFocusUtil.focusPrev(focusedActor, getRoot(), false, false, this)
                    || ActorFocusUtil.focusLastChild(getRoot(), this));
        }
        return checkScroll(ActorFocusUtil.focusNext(focusedActor, getRoot(), false, false, this)
                || ActorFocusUtil.focusFirstChild(getRoot(), this));
    }
    // alowed childs to consume key down
    boolean consumed = super.keyDown(keycode);
    if (!consumed && !awaitingKeyUp) {
        switch (keycode) {
        case Keys.SPACE:
            if (focusedActor != null)
                break;
            // else fall through
        case Keys.ENTER:
            return (awaitingKeyUp = actionKeyPressed(true));
        case Keys.ESCAPE:
            if (focusedActor != null) {
                setKeyboardFocus(null);
            }
            return false;
        case Keys.UP:
            if (!checkScroll(ActorFocusUtil.focusPrev(focusedActor, getRoot(), true, false, this))
                    && getScrollFocus() instanceof ScrollPane) {
                ScrollPane s = (ScrollPane) getScrollFocus();
                s.setScrollY(s.getScrollY() - SCROLL_PIXEL_AMOUNT);
            }
            return true;
        case Keys.DOWN:
            if (!checkScroll(ActorFocusUtil.focusNext(focusedActor, getRoot(), true, false, this))
                    && getScrollFocus() instanceof ScrollPane) {
                ScrollPane s = (ScrollPane) getScrollFocus();
                s.setScrollY(s.getScrollY() + SCROLL_PIXEL_AMOUNT);
            }
            return true;
        case Keys.LEFT:
            if (!checkScroll(ActorFocusUtil.focusPrev(focusedActor, getRoot(), false, true, this))
                    && getScrollFocus() instanceof ScrollPane) {
                ScrollPane s = (ScrollPane) getScrollFocus();
                s.setScrollX(s.getScrollX() - SCROLL_PIXEL_AMOUNT);
            }
            return true;
        case Keys.RIGHT:
            if (!checkScroll(ActorFocusUtil.focusNext(focusedActor, getRoot(), false, true, this))
                    && getScrollFocus() instanceof ScrollPane) {
                ScrollPane s = (ScrollPane) getScrollFocus();
                s.setScrollX(s.getScrollX() + SCROLL_PIXEL_AMOUNT);
            }
            return true;
        case Keys.PAGE_UP:
            if (getScrollFocus() instanceof ScrollPane) {
                ScrollPane s = (ScrollPane) getScrollFocus();
                s.setScrollY(s.getScrollY() - s.getHeight() * .7f);
            }
            return true;
        case Keys.PAGE_DOWN:
            if (getScrollFocus() instanceof ScrollPane) {
                ScrollPane s = (ScrollPane) getScrollFocus();
                s.setScrollY(s.getScrollY() + s.getHeight() * .7f);
            }
            return true;
        }
    }
    return consumed;
}