@Override public boolean handle(Event event) { if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent) event; if (Type.touchDown.equals(inputEvent.getType())) { Inventory junkBag = GameState.getPlayerCharacterGroup().getInventory(); if (junkBag.getTotalNumberOfItems() > 0) { int totalCost = junkBag.getTotalTradingCost(BagType.BACKPACK, getDisplayedCustomer(), displayedMerchant, false); UIManager.displayConfirmation( Strings.getString(UIManager.STRING_TABLE, "sellAllQuestion"), Strings.getString(UIManager.STRING_TABLE, "sellAllConfirmation", totalCost), callback); } return true; } } return false; }
public boolean handle(Event event) { if (item == null) { return false; } if (item.equals(UIManager.getDraggedItem())) { UIManager.hideToolTip(); return false; } if (event instanceof InputEvent) { Type inputEventType = ((InputEvent) event).getType(); if (Type.enter.equals(inputEventType)) { getTooltip().updateText(UIManager.getDisplayedCharacter()); if (getTooltip().shouldDisplay()) { UIManager.setToolTip(getTooltip()); } } if (Type.exit.equals(inputEventType)) { UIManager.hideToolTip(); } } return false; }
@Override public boolean handle(Event event) { // disable the combat path in case any UI element is being hovered if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent) event; if (Type.enter.equals(inputEvent.getType())) { overUIElement = true; if (UIManager.isThisTooltipSet(combatTooltip)) { UIManager.hideToolTip(); } } if (Type.exit.equals(inputEvent.getType())) { overUIElement = false; overCharacterPortrait = false; } if (Type.mouseMoved.equals(inputEvent.getType())) { Actor hitActor = UIManager.getStage().hit(inputEvent.getStageX(), inputEvent.getStageY(), true); overUIElement = hitActor != null; overCharacterPortrait = UIManager.isPCPortrait(hitActor); } } return false; }
private Actor fireEnterAndExit (Actor overLast, int screenX, int screenY, int pointer) { // Find the actor under the point. screenToStageCoordinates(tempCoords.set(screenX, screenY)); Actor over = hit(tempCoords.x, tempCoords.y, true); if (over == overLast) return overLast; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setStageX(tempCoords.x); event.setStageY(tempCoords.y); event.setPointer(pointer); // Exit overLast. if (overLast != null) { event.setType(InputEvent.Type.exit); event.setRelatedActor(over); overLast.fire(event); } // Enter over. if (over != null) { event.setType(InputEvent.Type.enter); event.setRelatedActor(overLast); over.fire(event); } Pools.free(event); return over; }
/** Applies a mouse moved event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the event. * This event only occurs on the desktop. */ public boolean mouseMoved (int screenX, int screenY) { if (screenX < viewport.getScreenX() || screenX >= viewport.getScreenX() + viewport.getScreenWidth()) return false; if (Gdx.graphics.getHeight() - screenY < viewport.getScreenY() || Gdx.graphics.getHeight() - screenY >= viewport.getScreenY() + viewport.getScreenHeight()) return false; mouseScreenX = screenX; mouseScreenY = screenY; screenToStageCoordinates(tempCoords.set(screenX, screenY)); InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(Type.mouseMoved); event.setStageX(tempCoords.x); event.setStageY(tempCoords.y); Actor target = hit(tempCoords.x, tempCoords.y, true); if (target == null) target = root; target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a mouse scroll event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the * event. This event only occurs on the desktop. */ public boolean scrolled (int amount) { Actor target = scrollFocus == null ? root : scrollFocus; screenToStageCoordinates(tempCoords.set(mouseScreenX, mouseScreenY)); InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.scrolled); event.setScrollAmount(amount); event.setStageX(tempCoords.x); event.setStageY(tempCoords.y); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Sets the actor that will receive key events. * @param actor May be null. */ public void setKeyboardFocus (Actor actor) { if (keyboardFocus == actor) return; FocusEvent event = Pools.obtain(FocusEvent.class); event.setStage(this); event.setType(FocusEvent.Type.keyboard); Actor oldKeyboardFocus = keyboardFocus; if (oldKeyboardFocus != null) { event.setFocused(false); event.setRelatedActor(actor); oldKeyboardFocus.fire(event); } if (!event.isCancelled()) { keyboardFocus = actor; if (actor != null) { event.setFocused(true); event.setRelatedActor(oldKeyboardFocus); actor.fire(event); if (event.isCancelled()) setKeyboardFocus(oldKeyboardFocus); } } Pools.free(event); }
/** Sets the actor that will receive scroll events. * @param actor May be null. */ public void setScrollFocus (Actor actor) { if (scrollFocus == actor) return; FocusEvent event = Pools.obtain(FocusEvent.class); event.setStage(this); event.setType(FocusEvent.Type.scroll); Actor oldScrollFocus = keyboardFocus; if (oldScrollFocus != null) { event.setFocused(false); event.setRelatedActor(actor); oldScrollFocus.fire(event); } if (!event.isCancelled()) { scrollFocus = actor; if (actor != null) { event.setFocused(true); event.setRelatedActor(oldScrollFocus); actor.fire(event); if (event.isCancelled()) setScrollFocus(oldScrollFocus); } } Pools.free(event); }
private void initialize() { if (cursorLocation == null) { cursor = GlobalResources.linkCursor; } else { cursor = new Pixmap(Gdx.files.internal(cursorLocation)); } listeners = new DelayedRemovalArray<EventListener>(); this.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof InputEvent) { Type type = ((InputEvent) event).getType(); if (type == Type.enter) { if (!me.isDisabled()) Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor, 4, 0)); return true; } else if (type == Type.exit) { Gdx.graphics.setSystemCursor(SystemCursor.Arrow); return true; } } return false; } }); }
private void initialize() { this.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof InputEvent) { Type type = ((InputEvent) event).getType(); if (type == Type.enter) { if (!me.isDisabled()) Gdx.graphics.setCursor(Gdx.graphics.newCursor(cursor != null ? cursor : GlobalResources.linkCursor, 4, 0)); return true; } else if (type == Type.exit) { Gdx.graphics.setSystemCursor(SystemCursor.Arrow); return true; } } return false; } }); }
private void initialize() { this.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof InputEvent) { Type type = ((InputEvent) event).getType(); // Click if (type == Type.touchUp && ((InputEvent) event).getButton() == Buttons.LEFT) { Gdx.net.openURI(linkURL); } else if (type == Type.enter) { Gdx.graphics.setCursor(Gdx.graphics.newCursor(GlobalResources.linkCursor, 4, 0)); } else if (type == Type.exit) { Gdx.graphics.setSystemCursor(SystemCursor.Arrow); } return true; } return false; } }); }
@Override public boolean handle(Event event) { if (event instanceof InputEvent) { InputEvent ev = (InputEvent) event; if (ev.getType() == Type.mouseMoved) { MouseEvent mevent = eventPool.obtain(); v.x = ev.getStageX(); v.y = ev.getStageY(); v = InputVisualizer.this.getStage() .stageToScreenCoordinates(v); mevent.x = v.x; mevent.y = Gdx.graphics.getHeight() - v.y; mevent.extent = 1; mevent.overGrown = false; MouseEvent overwritten; synchronized (eventBuffer) { overwritten = eventBuffer.push(mevent); } if (overwritten != null) { eventPool.free(overwritten); } } } return true; }
@Override public boolean handle(Event event) { if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent) event; if (Type.touchDown.equals(inputEvent.getType())) { clicked(inputEvent, inputEvent.getTarget()); } } return false; }
public boolean handle(Event event) { if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent) event; if (Type.enter.equals(inputEvent.getType())) { tooltip.updateText(character, !onlyKnownPerks); UIManager.setToolTip(tooltip); } if (Type.exit.equals(inputEvent.getType())) { UIManager.hideToolTip(); } } return false; }
public boolean handle(Event event) { if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent) event; if (Type.enter.equals(inputEvent.getType())) { tooltip.updateText(character); if (tooltip.shouldDisplay()) { UIManager.setToolTip(tooltip); } } if (Type.exit.equals(inputEvent.getType())) { UIManager.hideToolTip(); } } return false; }
public boolean handle(Event event) { if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent) event; if (Type.enter.equals(inputEvent.getType())) { UIManager.setToolTip(tooltip); } if (Type.exit.equals(inputEvent.getType())) { UIManager.hideToolTip(); } } return false; }
/** Notifies this actor's listeners of the event. The event is not propagated to any parents. Before notifying the listeners, * this actor is set as the {@link Event#getListenerActor() listener actor}. The event {@link Event#setTarget(Actor) target} * must be set before calling this method. If this actor is not in the stage, the stage must be set before calling this method. * @param capture If true, the capture listeners will be notified instead of the regular listeners. * @return true of the event was {@link Event#cancel() cancelled}. */ public boolean notify (Event event, boolean capture) { if (event.getTarget() == null) throw new IllegalArgumentException("The event target cannot be null."); DelayedRemovalArray<EventListener> listeners = capture ? captureListeners : this.listeners; if (listeners.size == 0) return event.isCancelled(); event.setListenerActor(this); event.setCapture(capture); if (event.getStage() == null) event.setStage(stage); listeners.begin(); for (int i = 0, n = listeners.size; i < n; i++) { EventListener listener = listeners.get(i); if (listener.handle(event)) { event.handle(); if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent)event; if (inputEvent.getType() == Type.touchDown) { event.getStage().addTouchFocus(listener, this, inputEvent.getTarget(), inputEvent.getPointer(), inputEvent.getButton()); } } } } listeners.end(); return event.isCancelled(); }
/** Calls the {@link Actor#act(float)} method on each actor in the stage. Typically called each frame. This method also fires * enter and exit events. * @param delta Time in seconds since the last frame. */ public void act (float delta) { // Update over actors. Done in act() because actors may change position, which can fire enter/exit without an input event. for (int pointer = 0, n = pointerOverActors.length; pointer < n; pointer++) { Actor overLast = pointerOverActors[pointer]; // Check if pointer is gone. if (!pointerTouched[pointer]) { if (overLast != null) { pointerOverActors[pointer] = null; screenToStageCoordinates(tempCoords.set(pointerScreenX[pointer], pointerScreenY[pointer])); // Exit over last. InputEvent event = Pools.obtain(InputEvent.class); event.setType(InputEvent.Type.exit); event.setStage(this); event.setStageX(tempCoords.x); event.setStageY(tempCoords.y); event.setRelatedActor(overLast); event.setPointer(pointer); overLast.fire(event); Pools.free(event); } continue; } // Update over actor for the pointer. pointerOverActors[pointer] = fireEnterAndExit(overLast, pointerScreenX[pointer], pointerScreenY[pointer], pointer); } // Update over actor for the mouse on the desktop. ApplicationType type = Gdx.app.getType(); if (type == ApplicationType.Desktop || type == ApplicationType.Applet || type == ApplicationType.WebGL) mouseOverActor = fireEnterAndExit(mouseOverActor, mouseScreenX, mouseScreenY, -1); // Run actions and determine whether to request rendering (for when setContinuousRendering is off) root.act(delta); }
/** Applies a touch down event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the event. */ public boolean touchDown (int screenX, int screenY, int pointer, int button) { if (screenX < viewport.getScreenX() || screenX >= viewport.getScreenX() + viewport.getScreenWidth()) return false; if (Gdx.graphics.getHeight() - screenY < viewport.getScreenY() || Gdx.graphics.getHeight() - screenY >= viewport.getScreenY() + viewport.getScreenHeight()) return false; pointerTouched[pointer] = true; pointerScreenX[pointer] = screenX; pointerScreenY[pointer] = screenY; screenToStageCoordinates(tempCoords.set(screenX, screenY)); InputEvent event = Pools.obtain(InputEvent.class); event.setType(Type.touchDown); event.setStage(this); event.setStageX(tempCoords.x); event.setStageY(tempCoords.y); event.setPointer(pointer); event.setButton(button); Actor target = hit(tempCoords.x, tempCoords.y, true); if (target == null) target = root; target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a key down event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns * true if the event was {@link Event#handle() handled}. */ public boolean keyDown (int keyCode) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyDown); event.setKeyCode(keyCode); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a key up event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns true * if the event was {@link Event#handle() handled}. */ public boolean keyUp (int keyCode) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyUp); event.setKeyCode(keyCode); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Applies a key typed event to the actor that has {@link Stage#setKeyboardFocus(Actor) keyboard focus}, if any, and returns * true if the event was {@link Event#handle() handled}. */ public boolean keyTyped (char character) { Actor target = keyboardFocus == null ? root : keyboardFocus; InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.keyTyped); event.setCharacter(character); target.fire(event); boolean handled = event.isHandled(); Pools.free(event); return handled; }
/** Cancels touch focus for the specified actor. * @see #cancelTouchFocus() */ public void cancelTouchFocus (Actor actor) { InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.touchUp); event.setStageX(Integer.MIN_VALUE); event.setStageY(Integer.MIN_VALUE); // Cancel all current touch focuses for the specified listener, allowing for concurrent modification, and never cancel the // same focus twice. SnapshotArray<TouchFocus> touchFocuses = this.touchFocuses; TouchFocus[] items = touchFocuses.begin(); for (int i = 0, n = touchFocuses.size; i < n; i++) { TouchFocus focus = items[i]; if (focus.listenerActor != actor) continue; if (!touchFocuses.removeValue(focus, true)) continue; // Touch focus already gone. event.setTarget(focus.target); event.setListenerActor(focus.listenerActor); event.setPointer(focus.pointer); event.setButton(focus.button); focus.listener.handle(event); // Cannot return TouchFocus to pool, as it may still be in use (eg if cancelTouchFocus is called from touchDragged). } touchFocuses.end(); Pools.free(event); }
/** Cancels touch focus for all listeners except the specified listener. * @see #cancelTouchFocus() */ public void cancelTouchFocusExcept (EventListener exceptListener, Actor exceptActor) { InputEvent event = Pools.obtain(InputEvent.class); event.setStage(this); event.setType(InputEvent.Type.touchUp); event.setStageX(Integer.MIN_VALUE); event.setStageY(Integer.MIN_VALUE); // Cancel all current touch focuses except for the specified listener, allowing for concurrent modification, and never // cancel the same focus twice. SnapshotArray<TouchFocus> touchFocuses = this.touchFocuses; TouchFocus[] items = touchFocuses.begin(); for (int i = 0, n = touchFocuses.size; i < n; i++) { TouchFocus focus = items[i]; if (focus.listener == exceptListener && focus.listenerActor == exceptActor) continue; if (!touchFocuses.removeValue(focus, true)) continue; // Touch focus already gone. event.setTarget(focus.target); event.setListenerActor(focus.listenerActor); event.setPointer(focus.pointer); event.setButton(focus.button); focus.listener.handle(event); // Cannot return TouchFocus to pool, as it may still be in use (eg if cancelTouchFocus is called from touchDragged). } touchFocuses.end(); Pools.free(event); }
@Override public Dialog show(Stage stage, Action action) { final Table content = getContentTable(); content.add(fileListLabel).top().left().expandX().fillX().row(); content.add(new ScrollPane(fileList, skin)).size(300, 150).fill().expand().row(); if (fileNameEnabled) { content.add(fileNameLabel).fillX().expandX().row(); content.add(fileNameInput).fillX().expandX().row(); stage.setKeyboardFocus(fileNameInput); } if (directoryBrowsingEnabled) { fileList.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { final FileListItem selected = fileList.getSelected(); if (selected.file.isDirectory() && TimeUtils.millis() - lastClick < 500) { changeDirectory(selected.file); lastClick = 0; } else if (event.getType() == Type.touchUp) { lastClick = TimeUtils.millis(); } } }); } changeDirectory(baseDir); return super.show(stage, action); }
private void inputEvent(Type type, String... names) { Actor actor = getActor(names); if (actor == null) { Gdx.app.error("EditorGUITest", "No actor with name " + Arrays.toString(names) + " for " + type); return; } inputEvent(type, 0, 0, 0, Buttons.LEFT, actor); Gdx.app.debug("EditorGUITest", type + " fired in " + Arrays.toString(names)); }
private void inputEvent(Type type, float x, float y, int pointer, int button) { switch (type) { case touchDown: editorDesktop.getStage().touchDown((int) x, (int) y, pointer, button); break; case touchUp: editorDesktop.getStage().touchUp((int) x, (int) y, pointer, button); break; case touchDragged: editorDesktop.getStage().touchDragged((int) x, (int) y, pointer); break; } }
public boolean handle(Event paramEvent) { if (super.handle(paramEvent)) { if (((InputEvent)paramEvent).getType() == InputEvent.Type.touchDown) this.this$0.flingTimer = 0.0F; return true; } return false; }
public final boolean handle(Event paramEvent) { if (super.handle(paramEvent)) { if (((InputEvent)paramEvent).getType() == InputEvent.Type.touchDown) WidgetCarousel.b(this.a, 0.0F); return true; } return false; }
@Override public boolean handle(Event event) { if ((event instanceof ChangeEvent)) { return changed((ChangeEvent)event, event.getTarget().getName()); } if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent) event; String targetName = inputEvent.getTarget().getName(); Type eventType = inputEvent.getType(); if (Type.touchUp == eventType) { if (UIManager.isCharacterScreenOpen() && UIManager.getDraggedItem() == null) { UIManager.closeMutuallyExclusiveScreens(); } } if (Type.enter == eventType) { boolean setTooltip = true; if (HUNT.equals(targetName)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "campHuntTooltip")); } else if (WATER.equals(targetName)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "campWaterTooltip")); } else if (SLEEP.equals(targetName)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "campSleepTooltip")); } else if (PACKUP.equals(targetName)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "campPackUpTooltip")); } else if (GATHER.equals(targetName)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "campGatherTooltip")); } else { setTooltip = false; } if (setTooltip) { UIManager.setToolTip(tooltip); } } if (Type.exit == eventType) { UIManager.hideToolTip(); } } return true; }
@Override public boolean handle(Event event) { if (group.getGroupLeader() != null) { if ((event instanceof ChangeEvent) && !ignoreEvent) { return changed((ChangeEvent)event, event.getTarget()); } } if (event instanceof InputEvent) { InputEvent inputEvent = (InputEvent) event; if (Type.enter.equals(inputEvent.getType())) { Actor target = inputEvent.getTarget(); if (inventoryButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "inventoryTooltip")); } else if (characterSheetButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "charsheetTooltip")); } else if (usePerkButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "usePerkTooltip")); } else if (journalButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "displayJournalTooltip")); } else if (spellbookButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "displaySpellbookTooltip")); } else if (activeEffectsButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "activeEffectsTooltip")); } else if (campButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, gameState.getCurrentMap().isWorldMap() ? "breakCampTooltip" : "restTooltip")); } else if (stealthButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "stealthTooltip")); } else if (lockpickButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "lockpickTooltip")); } else if (disarmTrapsButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "disarmTooltip")); } else if (detectTrapsButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "detectTrapsTooltip")); } else if (formationEditorButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "formationEditorTooltip")); } else if (attackButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "attackTooltip")); } else if (talkToButton.isAscendantOf(target)) { tooltip.setText(Strings.getString(UIManager.STRING_TABLE, "talkToTooltip")); } UIManager.setToolTip(tooltip); } else if (Type.exit.equals(inputEvent.getType())) { UIManager.hideToolTip(); } } return true; }
protected void rebuildGui() { if (ui != null) { ui.clear(); boolean collapsed = false; if (controlsWindow != null) { collapsed = controlsWindow.isCollapsed(); recalculateOptionsSize(); if (collapsed) controlsWindow.collapseInstant(); controlsWindow.setPosition(0, Gdx.graphics.getHeight() - controlsWindow.getHeight()); ui.addActor(controlsWindow); } if (webglInterface != null) ui.addActor(wgl); if (notificationsInterface != null) ui.addActor(notificationsInterface); if (messagesInterface != null) ui.addActor(messagesInterface); if (focusInterface != null && !GlobalConf.runtime.STRIPPED_FOV_MODE) ui.addActor(fi); if (runStateInterface != null && Constants.desktop) { ui.addActor(runStateInterface); } if (pointerXCoord != null && pointerYCoord != null) { ui.addActor(pointerXCoord); ui.addActor(pointerYCoord); } if (customInterface != null) { customInterface.reAddObjects(); } /** CAPTURE SCROLL FOCUS **/ ui.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof InputEvent) { InputEvent ie = (InputEvent) event; if (ie.getType() == Type.mouseMoved) { Actor scrollPanelAncestor = getScrollPanelAncestor(ie.getTarget()); ui.setScrollFocus(scrollPanelAncestor); } else if (ie.getType() == Type.touchDown) { if (ie.getTarget() instanceof TextField) ui.setKeyboardFocus(ie.getTarget()); } } return false; } private Actor getScrollPanelAncestor(Actor actor) { if (actor == null) { return null; } else if (actor instanceof ScrollPane) { return actor; } else { return getScrollPanelAncestor(actor.getParent()); } } }); } }
protected void rebuildGui() { if (ui != null) { ui.clear(); ui.addActor(buttonContainer); ui.addActor(engineGroup); ui.addActor(controlsGroup); ui.addActor(motionGroup); ui.addActor(nearestGroup); ui.addActor(thrustContainer); ui.addActor(thrustGroup); } /** CAPTURE SCROLL FOCUS **/ ui.addListener(new EventListener() { @Override public boolean handle(Event event) { if (event instanceof InputEvent) { InputEvent ie = (InputEvent) event; if (ie.getType() == Type.mouseMoved) { Actor scrollPanelAncestor = getScrollPanelAncestor(ie.getTarget()); ui.setScrollFocus(scrollPanelAncestor); } else if (ie.getType() == Type.touchDown) { if (ie.getTarget() instanceof TextField) ui.setKeyboardFocus(ie.getTarget()); } } return false; } private Actor getScrollPanelAncestor(Actor actor) { if (actor == null) { return null; } else if (actor instanceof ScrollPane) { return actor; } else { return getScrollPanelAncestor(actor.getParent()); } } }); }
protected void press(String... actorName) { inputEvent(Type.touchDown, actorName); }
protected void release(String... actorName) { inputEvent(Type.touchUp, actorName); }
protected void press(int screenX, int screenY, int pointer, int button) { inputEvent(Type.touchDown, screenX, screenY, pointer, button); }
protected void drag(int screenX, int screenY, int pointer) { inputEvent(Type.touchDragged, screenX, screenY, pointer, 0); }