Example usage for com.badlogic.gdx.scenes.scene2d Stage setScrollFocus

List of usage examples for com.badlogic.gdx.scenes.scene2d Stage setScrollFocus

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d Stage setScrollFocus.

Prototype

public void setScrollFocus(Actor actor) 

Source Link

Document

Sets the actor that will receive scroll events.

Usage

From source file:com.aia.hichef.ui.n.MyDialog.java

License:Apache License

/** {@link #pack() Packs} the dialog and adds it to the stage, centered. */
public MyDialog show(Stage stage) {
    clearActions();/*from   www.java2 s .  c  o m*/
    removeCaptureListener(ignoreTouchDown);

    previousKeyboardFocus = null;
    Actor actor = stage.getKeyboardFocus();
    if (actor != null && !actor.isDescendantOf(this))
        previousKeyboardFocus = actor;

    previousScrollFocus = null;
    actor = stage.getScrollFocus();
    if (actor != null && !actor.isDescendantOf(this))
        previousScrollFocus = actor;

    pack();
    setPosition(Math.round((stage.getWidth() - getWidth()) / 2),
            Math.round((stage.getHeight() - getHeight()) / 2));
    stage.addActor(this);
    stage.setKeyboardFocus(this);
    stage.setScrollFocus(this);
    if (fadeDuration > 0) {
        getColor().a = 0;
        addAction(Actions.fadeIn(fadeDuration, Interpolation.fade));
    }
    return this;
}

From source file:com.aia.hichef.ui.n.MyDialog.java

License:Apache License

/**
 * Hides the dialog. Called automatically when a button is clicked. The
 * default implementation fades out the dialog over {@link #fadeDuration}
 * seconds and then removes it from the stage.
 *//*w ww  . j av  a  2  s.  com*/
public void hide() {
    Stage stage = getStage();
    if (stage != null) {
        if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null)
            previousKeyboardFocus = null;
        Actor actor = stage.getKeyboardFocus();
        if (actor == null || actor.isDescendantOf(this))
            stage.setKeyboardFocus(previousKeyboardFocus);

        if (previousScrollFocus != null && previousScrollFocus.getStage() == null)
            previousScrollFocus = null;
        actor = stage.getScrollFocus();
        if (actor == null || actor.isDescendantOf(this))
            stage.setScrollFocus(previousScrollFocus);
    }
    if (fadeDuration > 0) {
        addCaptureListener(ignoreTouchDown);
        addAction(sequence(fadeOut(fadeDuration, Interpolation.fade),
                Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
    } else
        remove();
}

From source file:com.kotcrab.vis.editor.util.scene2d.FocusUtils.java

License:Apache License

public static void focus(Stage stage, Actor target) {
    stage.setKeyboardFocus(target);
    stage.setScrollFocus(target);
}

From source file:com.ray3k.skincomposer.dialog.DialogColors.java

License:Open Source License

@Override
public Dialog show(Stage stage) {
    Dialog dialog = super.show(stage);
    stage.setScrollFocus(scrollPane);
    return dialog;
}

From source file:com.ray3k.skincomposer.dialog.DialogDrawables.java

License:Open Source License

@Override
public Dialog show(Stage stage, Action action) {
    Dialog dialog = super.show(stage, action);
    stage.setScrollFocus(scrollPane);
    validate();//w w w.  j  a va  2s. c  o m
    scrollPane.setScrollY(scrollPosition);
    return dialog;
}

From source file:es.eucm.ead.editor.view.widgets.Dialog.java

License:Open Source License

/**
 * Shows the dialog in the stage//  ww w  .  j  a va  2s  .  c  o m
 */
public void show(Stage stage) {
    previousKeyboardFocus = null;
    Actor actor = stage.getKeyboardFocus();
    if (actor != null && !actor.isDescendantOf(this))
        previousKeyboardFocus = actor;

    previousScrollFocus = null;
    actor = stage.getScrollFocus();
    if (actor != null && !actor.isDescendantOf(this))
        previousScrollFocus = actor;

    stage.addActor(this);
    stage.setKeyboardFocus(this);
    stage.setScrollFocus(this);

}

From source file:es.eucm.ead.editor.view.widgets.Dialog.java

License:Open Source License

/**
 * Hides the dialog/* w ww  . j a v  a 2  s .c om*/
 */
public void hide() {
    Stage stage = getStage();
    if (stage != null) {
        if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null)
            previousKeyboardFocus = null;
        Actor actor = stage.getKeyboardFocus();
        if (actor == null || actor.isDescendantOf(this))
            stage.setKeyboardFocus(previousKeyboardFocus);

        if (previousScrollFocus != null && previousScrollFocus.getStage() == null)
            previousScrollFocus = null;
        actor = stage.getScrollFocus();
        if (actor == null || actor.isDescendantOf(this))
            stage.setScrollFocus(previousScrollFocus);
    }
    remove();
}