/** Returns true if this actor is a listener actor for touch focus. * @see Stage#addTouchFocus(EventListener, Actor, Actor, int, int) */ public boolean isTouchFocusListener () { Stage stage = getStage(); if (stage == null) return false; for (int i = 0, n = stage.touchFocuses.size; i < n; i++) if (stage.touchFocuses.get(i).listenerActor == this) return true; return false; }
/** 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#getScrollFocus() scroll focus} actor. */ public boolean hasScrollFocus () { Stage stage = getStage(); return stage != null && stage.getScrollFocus() == 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; }
public Target (Actor actor) { if (actor == null) throw new IllegalArgumentException("actor cannot be null."); this.actor = actor; Stage stage = actor.getStage(); if (stage != null && actor == stage.getRoot()) throw new IllegalArgumentException("The stage root cannot be a drag and drop target."); }
/** 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; }
/** Returns true if this actor is a listener actor for touch focus. * @see Stage#addTouchFocus(EventListener, Actor, Actor, int, int) */ public boolean isTouchFocusListener () { Stage stage = getStage(); if (stage == null) return false; for (int i = 0, n = stage.touchFocuses.size; i < n; i++) if (stage.touchFocuses.get(i).listenerActor == this) return true; return false; }
/** Returns true if this actor is a target actor for touch focus. * @see Stage#addTouchFocus(EventListener, Actor, Actor, int, int) */ public boolean isTouchFocusTarget () { Stage stage = getStage(); if (stage == null) return false; for (int i = 0, n = stage.touchFocuses.size; i < n; i++) if (stage.touchFocuses.get(i).target == this) return true; return false; }
public Target (Actor actor) { if (actor == null) throw new IllegalArgumentException("actor cannot be null."); this.actor = actor; Stage stage = actor.getStage(); if (stage != null && actor == stage.getRoot()) throw new IllegalArgumentException("The stage root cannot be a drag and drop target."); }
/** Returns true if this actor is a target actor for touch focus. * @see Stage#addTouchFocus(EventListener, Actor, Actor, int, int) */ public boolean isTouchFocusTarget () { Stage stage = getStage(); if (stage == null) return false; for (int i = 0, n = stage.touchFocuses.size; i < n; i++) if (stage.touchFocuses.get(i).target == this) return true; return false; }
public void act (float delta) { super.act(delta); if (targetActor != null && targetActor.getStage() == null) remove(); } };
public void act (float delta) { super.act(delta); if (targetActor != null && targetActor.getStage() == null) remove(); } };
/** Cancels the touch focus for everything except the specified source. */ public void cancelTouchFocusExcept (Source except) { DragListener listener = sourceListeners.get(except); if (listener == null) return; except.getActor().getStage().cancelTouchFocusExcept(listener, except.getActor()); }
/** Cancels the touch focus for everything except the specified source. */ public void cancelTouchFocusExcept (Source except) { DragListener listener = sourceListeners.get(except); if (listener == null) return; except.getActor().getStage().cancelTouchFocusExcept(listener, except.getActor()); }
public void dragStart (InputEvent event, float x, float y, int pointer) { if (activePointer != -1) { event.stop(); return; } activePointer = pointer; dragStartTime = System.currentTimeMillis(); dragSource = source; payload = source.dragStart(event, getTouchDownX(), getTouchDownY(), pointer); event.stop(); if (cancelTouchFocus && payload != null) source.getActor().getStage().cancelTouchFocusExcept(this, source.getActor()); }
public void dragStart (InputEvent event, float x, float y, int pointer) { if (activePointer != -1) { event.stop(); return; } activePointer = pointer; dragStartTime = System.currentTimeMillis(); dragSource = source; payload = source.dragStart(event, getTouchDownX(), getTouchDownY(), pointer); event.stop(); if (cancelTouchFocus && payload != null) source.getActor().getStage().cancelTouchFocusExcept(this, source.getActor()); }
public void run () { if (showTooltip == null || showTooltip.targetActor == null) return; Stage stage = showTooltip.targetActor.getStage(); if (stage == null) return; stage.addActor(showTooltip.container); showTooltip.container.toFront(); shown.add(showTooltip); showTooltip.container.clearActions(); showAction(showTooltip); if (!showTooltip.instant) { time = subsequentTime; resetTask.cancel(); } } };
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); }
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); }
private void setContainerPosition (Actor actor, float x, float y) { this.targetActor = actor; Stage stage = actor.getStage(); if (stage == null) return; container.pack(); float offsetX = manager.offsetX, offsetY = manager.offsetY, dist = manager.edgeDistance; Vector2 point = actor.localToStageCoordinates(tmp.set(x + offsetX, y - offsetY - container.getHeight())); if (point.y < dist) point = actor.localToStageCoordinates(tmp.set(x + offsetX, y + offsetY)); if (point.x < dist) point.x = dist; if (point.x + container.getWidth() > stage.getWidth() - dist) point.x = stage.getWidth() - dist - container.getWidth(); if (point.y + container.getHeight() > stage.getHeight() - dist) point.y = stage.getHeight() - dist - container.getHeight(); container.setPosition(point.x, point.y); point = actor.localToStageCoordinates(tmp.set(actor.getWidth() / 2, actor.getHeight() / 2)); point.sub(container.getX(), container.getY()); container.setOrigin(point.x, point.y); }