com.badlogic.gdx.scenes.scene2d.Stage.getScrollFocus()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.getScrollFocus()方法的一些代码示例,展示了Stage.getScrollFocus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.getScrollFocus()方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:getScrollFocus

Stage.getScrollFocus介绍

[英]Gets the actor that will receive scroll events.
[中]获取将接收滚动事件的参与者。

代码示例

代码示例来源:origin: libgdx/libgdx

/** Returns true if this actor is the {@link Stage#getScrollFocus() scroll focus} actor. */
public boolean hasScrollFocus () {
  Stage stage = getStage();
  return stage != null && stage.getScrollFocus() == this;
}

代码示例来源:origin: libgdx/libgdx

/** Returns true if this actor is the {@link Stage#getScrollFocus() scroll focus} actor. */
public boolean hasScrollFocus () {
  Stage stage = getStage();
  return stage != null && stage.getScrollFocus() == this;
}

代码示例来源:origin: libgdx/libgdx

public void hide () {
  if (!list.isTouchable() || !hasParent()) return;
  list.setTouchable(Touchable.disabled);
  Stage stage = getStage();
  if (stage != null) {
    stage.removeCaptureListener(hideListener);
    stage.removeListener(list.getKeyListener());
    if (previousScrollFocus != null && previousScrollFocus.getStage() == null) previousScrollFocus = null;
    Actor actor = stage.getScrollFocus();
    if (actor == null || isAscendantOf(actor)) stage.setScrollFocus(previousScrollFocus);
  }
  clearActions();
  selectBox.onHide(this);
}

代码示例来源:origin: libgdx/libgdx

public void hide () {
  if (!list.isTouchable() || !hasParent()) return;
  list.setTouchable(Touchable.disabled);
  Stage stage = getStage();
  if (stage != null) {
    stage.removeCaptureListener(hideListener);
    stage.removeListener(list.getKeyListener());
    if (previousScrollFocus != null && previousScrollFocus.getStage() == null) previousScrollFocus = null;
    Actor actor = stage.getScrollFocus();
    if (actor == null || isAscendantOf(actor)) stage.setScrollFocus(previousScrollFocus);
  }
  clearActions();
  selectBox.onHide(this);
}

代码示例来源:origin: libgdx/libgdx

/** {@link #pack() Packs} the dialog (but doesn't set the position), adds it to the stage, sets it as the keyboard and scroll
 * focus, clears any actions on the dialog, and adds the specified action to it. The previous keyboard and scroll focus are
 * remembered so they can be restored when the dialog is hidden.
 * @param action May be null. */
public Dialog show (Stage stage, Action action) {
  clearActions();
  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();
  stage.addActor(this);
  stage.cancelTouchFocus();
  stage.setKeyboardFocus(this);
  stage.setScrollFocus(this);
  if (action != null) addAction(action);
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** {@link #pack() Packs} the dialog (but doesn't set the position), adds it to the stage, sets it as the keyboard and scroll
 * focus, clears any actions on the dialog, and adds the specified action to it. The previous keyboard and scroll focus are
 * remembered so they can be restored when the dialog is hidden.
 * @param action May be null. */
public Dialog show (Stage stage, Action action) {
  clearActions();
  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();
  stage.addActor(this);
  stage.cancelTouchFocus();
  stage.setKeyboardFocus(this);
  stage.setScrollFocus(this);
  if (action != null) addAction(action);
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** Removes the dialog from the stage, restoring the previous keyboard and scroll focus, and adds the specified action to the
 * dialog.
 * @param action If null, the dialog is removed immediately. Otherwise, the dialog is removed when the action completes. The
 *           dialog will not respond to touch down events during the action. */
public void hide (Action action) {
  Stage stage = getStage();
  if (stage != null) {
    removeListener(focusListener);
    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 (action != null) {
    addCaptureListener(ignoreTouchDown);
    addAction(sequence(action, Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
  } else
    remove();
}

代码示例来源:origin: libgdx/libgdx

/** Removes the dialog from the stage, restoring the previous keyboard and scroll focus, and adds the specified action to the
 * dialog.
 * @param action If null, the dialog is removed immediately. Otherwise, the dialog is removed when the action completes. The
 *           dialog will not respond to touch down events during the action. */
public void hide (Action action) {
  Stage stage = getStage();
  if (stage != null) {
    removeListener(focusListener);
    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 (action != null) {
    addCaptureListener(ignoreTouchDown);
    addAction(sequence(action, Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
  } else
    remove();
}

代码示例来源:origin: libgdx/libgdx

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

代码示例来源:origin: libgdx/libgdx

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

代码示例来源:origin: langurmonkey/gaiasky

/**
 * Removes the focus from this Gui and returns true if the focus was in the
 * GUI, false otherwise.
 * 
 * @return true if the focus was in the GUI, false otherwise.
 */
public boolean cancelTouchFocus() {
  if (ui.getScrollFocus() != null) {
    ui.setScrollFocus(null);
    ui.setKeyboardFocus(null);
    return true;
  }
  return false;
}

代码示例来源:origin: langurmonkey/gaiasky

/**
 * Removes the focus from this Gui and returns true if the focus was in the
 * GUI, false otherwise.
 *
 * @return true if the focus was in the GUI, false otherwise.
 */
public boolean cancelTouchFocus() {
  if (ui.getScrollFocus() != null) {
    ui.setScrollFocus(null);
    ui.setKeyboardFocus(null);
    return true;
  }
  return false;
}

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
  Actor actor = event.getListenerActor();
  Stage stage = actor.getStage();
  if (stage == null) return;
  if (stage.getScrollFocus() != actor) {
    stage.setScrollFocus(actor);
  }
}

代码示例来源:origin: langurmonkey/gaiasky

@Override
public boolean cancelTouchFocus() {
  if (ui.getKeyboardFocus() != null || ui.getScrollFocus() != null) {
    ui.setScrollFocus(null);
    ui.setKeyboardFocus(null);
    return true;
  }
  return false;
}

代码示例来源:origin: langurmonkey/gaiasky

@Override
public boolean cancelTouchFocus() {
  if (ui.getKeyboardFocus() != null || ui.getScrollFocus() != null) {
    ui.setScrollFocus(null);
    ui.setKeyboardFocus(null);
    return true;
  }
  return false;
}

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

@Override
  public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
    Actor actor = event.getListenerActor();
    Stage stage = actor.getStage();
    if (stage == null) return;

    // Stage fires "exit" event upon touchUp() even if pointer is still over the actor.
    // This is simple workaround.
    if (x > 0 && y > 0 && x < actor.getWidth() && y < actor.getHeight()) return;

    if (stage.getScrollFocus() == actor) {
      stage.setScrollFocus(null);
    }
  }
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

public void hide () {
  if (!list.isTouchable() || !hasParent()) return;
  list.setTouchable(Touchable.disabled);
  Stage stage = getStage();
  if (stage != null) {
    stage.removeCaptureListener(hideListener);
    if (previousScrollFocus != null && previousScrollFocus.getStage() == null) previousScrollFocus = null;
    Actor actor = stage.getScrollFocus();
    if (actor == null || isAscendantOf(actor)) stage.setScrollFocus(previousScrollFocus);
  }
  clearActions();
  selectBox.onHide(this);
}

代码示例来源:origin: kotcrab/vis-ui

/** {@link #pack() Packs} the dialog and adds it to the stage with custom action which can be null for instant show */
public VisDialog show (Stage stage, Action action) {
  clearActions();
  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();
  stage.addActor(this);
  stage.setKeyboardFocus(this);
  stage.setScrollFocus(this);
  if (action != null) addAction(action);
  return this;
}

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

public void hide() {
  if (!list.isTouchable() || !hasParent())
    return;
  list.setTouchable(Touchable.disabled);
  Stage stage = getStage();
  if (stage != null) {
    stage.removeCaptureListener(hideListener);
    if (previousScrollFocus != null && previousScrollFocus.getStage() == null)
      previousScrollFocus = null;
    Actor actor = stage.getScrollFocus();
    if (actor == null || isAscendantOf(actor))
      stage.setScrollFocus(previousScrollFocus);
  }
  clearActions();
  getColor().a = 1;
  addAction(sequence(fadeOut(0.15f, Interpolation.fade), Actions.removeActor()));
}

代码示例来源:origin: kotcrab/vis-ui

/** Hides the dialog with the given action and then removes it from the stage. */
public void hide (Action action) {
  Stage stage = getStage();
  if (stage != null) {
    removeListener(focusListener);
    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 (action != null) {
    addCaptureListener(ignoreTouchDown);
    addAction(sequence(action, Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
  } else
    remove();
}

相关文章