/** Removes the touch, keyboard, and scroll focused actors. */ public void unfocusAll () { setScrollFocus(null); setKeyboardFocus(null); cancelTouchFocus(); }
/** Removes the touch, keyboard, and scroll focused actors. */ public void unfocusAll () { setScrollFocus(null); setKeyboardFocus(null); cancelTouchFocus(); }
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (!super.touchDown(event, x, y, pointer, button)) return false; if (pointer == 0 && button != 0) return false; if (disabled) return true; setCursorPosition(x, y); selectionStart = cursor; Stage stage = getStage(); if (stage != null) stage.setKeyboardFocus(TextField.this); keyboard.show(true); hasSelection = true; return true; }
/** Removes the touch, keyboard, and scroll focus for the specified actor and any descendants. */ public void unfocus (Actor actor) { cancelTouchFocus(actor); if (scrollFocus != null && scrollFocus.isDescendantOf(actor)) setScrollFocus(null); if (keyboardFocus != null && keyboardFocus.isDescendantOf(actor)) setKeyboardFocus(null); }
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (!super.touchDown(event, x, y, pointer, button)) return false; if (pointer == 0 && button != 0) return false; if (disabled) return true; setCursorPosition(x, y); selectionStart = cursor; Stage stage = getStage(); if (stage != null) stage.setKeyboardFocus(TextField.this); keyboard.show(true); hasSelection = true; return true; }
/** Removes the touch, keyboard, and scroll focus for the specified actor and any descendants. */ public void unfocus (Actor actor) { cancelTouchFocus(actor); if (scrollFocus != null && scrollFocus.isDescendantOf(actor)) setScrollFocus(null); if (keyboardFocus != null && keyboardFocus.isDescendantOf(actor)) setKeyboardFocus(null); }
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (pointer != 0 || button != 0) return true; if (selection.isDisabled()) return true; getStage().setKeyboardFocus(List.this); if (items.size == 0) return true; int index = getItemIndexAt(y); if (index == -1) return true; selection.choose(items.get(index)); touchDown = index; return true; }
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (pointer != 0 || button != 0) return true; if (selection.isDisabled()) return true; getStage().setKeyboardFocus(List.this); if (items.size == 0) return true; int index = getItemIndexAt(y); if (index == -1) return true; selection.choose(items.get(index)); touchDown = index; return true; }
/** {@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(); }
return true; case Keys.ESCAPE: getStage().setKeyboardFocus(null); return true;
/** Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage. * @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest. */ public void next (boolean up) { Stage stage = getStage(); if (stage == null) return; TextField current = this; Vector2 currentCoords = current.getParent().localToStageCoordinates(tmp2.set(current.getX(), current.getY())); Vector2 bestCoords = tmp1; while (true) { TextField textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up); if (textField == null) { // Try to wrap around. if (up) currentCoords.set(Float.MIN_VALUE, Float.MIN_VALUE); else currentCoords.set(Float.MAX_VALUE, Float.MAX_VALUE); textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up); } if (textField == null) { Gdx.input.setOnscreenKeyboardVisible(false); break; } if (stage.setKeyboardFocus(textField)) { textField.selectAll(); break; } current = textField; currentCoords.set(bestCoords); } }
/** Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage. * @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest. */ public void next (boolean up) { Stage stage = getStage(); if (stage == null) return; TextField current = this; Vector2 currentCoords = current.getParent().localToStageCoordinates(tmp2.set(current.getX(), current.getY())); Vector2 bestCoords = tmp1; while (true) { TextField textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up); if (textField == null) { // Try to wrap around. if (up) currentCoords.set(Float.MIN_VALUE, Float.MIN_VALUE); else currentCoords.set(Float.MAX_VALUE, Float.MAX_VALUE); textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up); } if (textField == null) { Gdx.input.setOnscreenKeyboardVisible(false); break; } if (stage.setKeyboardFocus(textField)) { textField.selectAll(); break; } current = textField; currentCoords.set(bestCoords); } }
return true; case Keys.ESCAPE: getStage().setKeyboardFocus(null); return true;
@Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { FocusManager.switchFocus(getChooserStage(), FileItem.this); getChooserStage().setKeyboardFocus(FileItem.this); return true; }
@Override protected void setStage (Stage stage) { super.setStage(stage); if (stage != null) { stage.setKeyboardFocus(this); //issue #10, newly created window does not acquire keyboard focus if (centerOnAdd) { centerOnAdd = false; moveToCenter(); } } }