/** Returns true if this actor is the {@link Stage#getKeyboardFocus() keyboard focus} actor. */ public boolean hasKeyboardFocus () { Stage stage = getStage(); return stage != null && stage.getKeyboardFocus() == this; }
/** Returns true if this actor is the {@link Stage#getKeyboardFocus() keyboard focus} actor. */ public boolean hasKeyboardFocus () { Stage stage = getStage(); return stage != null && stage.getKeyboardFocus() == this; }
/** {@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; }
/** {@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; }
public void draw (Batch batch, float parentAlpha) { Stage stage = getStage(); if (stage.getKeyboardFocus() == null) stage.setKeyboardFocus(this); keepWithinStage(); if (style.stageBackground != null) { stageToLocalCoordinates(tmpPosition.set(0, 0)); stageToLocalCoordinates(tmpSize.set(stage.getWidth(), stage.getHeight())); drawStageBackground(batch, parentAlpha, getX() + tmpPosition.x, getY() + tmpPosition.y, getX() + tmpSize.x, getY() + tmpSize.y); } super.draw(batch, parentAlpha); }
public void draw (Batch batch, float parentAlpha) { Stage stage = getStage(); if (stage.getKeyboardFocus() == null) stage.setKeyboardFocus(this); keepWithinStage(); if (style.stageBackground != null) { stageToLocalCoordinates(tmpPosition.set(0, 0)); stageToLocalCoordinates(tmpSize.set(stage.getWidth(), stage.getHeight())); drawStageBackground(batch, parentAlpha, getX() + tmpPosition.x, getY() + tmpPosition.y, getX() + tmpSize.x, getY() + tmpSize.y); } super.draw(batch, parentAlpha); }
/** 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(); }
/** 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(); }
@Override public boolean keyDown (InputEvent event, int keycode) { if (keycode == Keys.A && UIUtils.ctrl() && getChooserStage().getKeyboardFocus() instanceof VisTextField == false) { selectAll(); return true; } return false; }
private Drawable getBackgroundDrawable () { Stage stage = getStage(); boolean focused = stage != null && stage.getKeyboardFocus() == this; return (disabled && style.disabledBackground != null) ? style.disabledBackground : ((focused && style.focusedBackground != null) ? style.focusedBackground : style.background); }
@Override public boolean keyTyped (InputEvent event, char character) { if (getChooserStage().getKeyboardFocus() instanceof VisTextField) return false; if (Character.isLetterOrDigit(character) == false) return false; String name = String.valueOf(character); for (FileHandle file : currentFiles) { if (file.name().toLowerCase().startsWith(name)) { deselectAll(); highlightFiles(file); return true; } } return false; } });
/** * Takes focus from current focused widget (if any), and sets current focused widget to null * @param stage if passed stage is not null then stage keyboard focus will be set to null only if current * focus owner is passed actor */ public static void resetFocus (Stage stage, Actor caller) { if (focusedWidget != null) focusedWidget.focusLost(); if (stage != null && stage.getKeyboardFocus() == caller) stage.setKeyboardFocus(null); focusedWidget = null; }
@Override public boolean cancelTouchFocus() { if (ui.getKeyboardFocus() != null || ui.getScrollFocus() != null) { ui.setScrollFocus(null); ui.setKeyboardFocus(null); return true; } return false; }
@Override public boolean cancelTouchFocus() { if (ui.getKeyboardFocus() != null || ui.getScrollFocus() != null) { ui.setScrollFocus(null); ui.setKeyboardFocus(null); return true; } return false; }
private void updateSelectedFileFieldText (boolean ignoreKeyboardFocus) { if (ignoreKeyboardFocus == false && getChooserStage() != null) { if (getChooserStage().getKeyboardFocus() == selectedFileTextField) return; } if (selectedItems.size == 0) { selectedFileTextField.setText(""); } else if (selectedItems.size == 1) { selectedFileTextField.setText(selectedItems.get(0).getFile().name()); } else { StringBuilder builder = new StringBuilder(); for (FileItem item : selectedItems) { builder.append('"'); builder.append(item.file.name()); builder.append("\" "); } selectedFileTextField.setText(builder.toString()); } selectedFileTextField.setCursorAtTextEnd(); }
/** {@link #pack() Packs} the dialog and adds it to the stage, centered. */ public Dialog show (Stage stage) { 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(); 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; }
/** {@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; }
public void draw (Batch batch, float parentAlpha) { Stage stage = getStage(); if (stage.getKeyboardFocus() == null) stage.setKeyboardFocus(this); keepWithinStage(); if (style.stageBackground != null) { stageToLocalCoordinates(tmpPosition.set(0, 0)); stageToLocalCoordinates(tmpSize.set(stage.getWidth(), stage.getHeight())); drawStageBackground(batch, parentAlpha, getX() + tmpPosition.x, getY() + tmpPosition.y, getX() + tmpSize.x, getY() + tmpSize.y); } super.draw(batch, parentAlpha); }
public void draw (Batch batch, float parentAlpha) { Stage stage = getStage(); if (stage.getKeyboardFocus() == null) stage.setKeyboardFocus(this); keepWithinStage(); if (style.stageBackground != null) { stageToLocalCoordinates(tmpPosition.set(0, 0)); stageToLocalCoordinates(tmpSize.set(stage.getWidth(), stage.getHeight())); drawStageBackground(batch, parentAlpha, getX() + tmpPosition.x, getY() + tmpPosition.y, getX() + tmpSize.x, getY() + tmpSize.y); } super.draw(batch, parentAlpha); }
/** 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(); }