com.badlogic.gdx.scenes.scene2d.InputEvent Java Examples
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.InputEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EffectRosterViewController.java From gdx-vfx with Apache License 2.0 | 6 votes |
private void addEffectToChain(final EffectEntryModel effectModel) { if (effectsChain.containsKey(effectModel)) { // If the effect is already in the chain, re-add it to the end of the list. removeEffectFromChain(effectModel); } EffectEntryViewController viewController = new EffectEntryViewController(lmlParser, effectModel); Group viewRoot = viewController.getViewRoot(); vgEffectsChain.addActor(viewRoot); effectsChain.put(viewController.getModel(), viewController); vfxManager.addEffect(viewController.getModel().getEffect()); viewRoot.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { removeEffectFromChain(effectModel); } }); }
Example #2
Source File: ImageChooserField.java From Mundus with Apache License 2.0 | 6 votes |
private void setupListeners() { fcBtn.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); FileChooser fileChooser = UI.INSTANCE.getFileChooser(); fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES); fileChooser.setListener(new SingleFileChooserListener() { public void selected(FileHandle file) { if (FileFormatUtils.isImage(file)) { setImage(file); } else { Dialogs.showErrorDialog(UI.INSTANCE, "This is no image"); } } }); UI.INSTANCE.addActor(fileChooser.fadeIn()); } }); }
Example #3
Source File: EditorLogger.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
public static void setConsole(Console console) { EditorLogger.console = console; EditorLogger.console.setDisplayKeyID(Keys.F1); console.setMaxEntries(1000); final Stage s = (Stage) console.getInputProcessor(); final Actor actor = s.getActors().items[0]; actor.addListener(new InputListener() { @Override public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { if (toActor == null) { s.setScrollFocus(null); } } }); console.setCommandExecutor(new EditorCommandExecutor()); }
Example #4
Source File: Scene2dUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
public static void simulateClickGlobal(Actor actor, int button, int pointer, float stageX, float stageY) { InputEvent event = Pools.obtain(InputEvent.class); event.setStage(actor.getStage()); event.setRelatedActor(actor); event.setTarget(actor); event.setStageX(stageX); event.setStageY(stageY); event.setButton(button); event.setPointer(pointer); event.setType(InputEvent.Type.touchDown); actor.notify(event, false); event.setType(InputEvent.Type.touchUp); actor.notify(event, false); Pools.free(event); }
Example #5
Source File: OnBackPressedLmlAttribute.java From gdx-vfx with Apache License 2.0 | 6 votes |
@Override public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) { final ActorConsumer<?, Actor> action = parser.parseAction(rawAttributeData, actor); if (action == null) { parser.throwError("Could not find action for: " + rawAttributeData + " with actor: " + actor); } actor.addListener(new InputListener() { @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Keys.BACK || keycode == Keys.ESCAPE) { action.consume(actor); return true; } return false; } }); }
Example #6
Source File: AllowTouchDownToActor.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
@Override public final void start(final Callback callback) { final Actor target = getTargetActor(); stage = target.getStage(); if (stage == null) throw new IllegalStateException("actor not on stage!"); listener = new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (!event.getTarget().isDescendantOf(target)) { event.cancel(); return false; } return true; } }; stage.addCaptureListener(listener); resources.put("allowTouchDownTo", listener); callback.taskEnded(); }
Example #7
Source File: MainMenu.java From talos with Apache License 2.0 | 6 votes |
public void updateRecentsList(Array<String> list) { openRecentPopup.clear(); for(String path: list) { final FileHandle handle = Gdx.files.absolute(path); if(!handle.exists()) continue;; String name = handle.name(); MenuItem item = new MenuItem(name); item.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); if(handle.extension().equals("tls")) { TalosMain.Instance().ProjectController().setProject(ProjectController.TLS); TalosMain.Instance().ProjectController().loadProject(handle); } else { TalosMain.Instance().Addons().projectFileDrop(handle); } } }); openRecentPopup.addItem(item); } }
Example #8
Source File: ModuleBoardWidget.java From talos with Apache License 2.0 | 6 votes |
public ModuleBoardWidget(NodeStage mainStage) { super(); this.mainStage = mainStage; curvePoints[0] = new Vector2(); curvePoints[1] = new Vector2(); curvePoints[2] = new Vector2(); curvePoints[3] = new Vector2(); addActor(groupContainer); addActor(moduleContainer); shapeRenderer = new ShapeRenderer(); addListener(new ClickListener() { @Override public boolean keyUp(InputEvent event, int keycode) { if(event.isHandled()) return super.keyUp(event, keycode); if(keycode == Input.Keys.DEL || keycode == Input.Keys.FORWARD_DEL) { deleteSelectedWrappers(); } return super.keyUp(event, keycode); } }); }
Example #9
Source File: AttachmentTypeToggle.java From talos with Apache License 2.0 | 6 votes |
public AttachmentTypeToggle(Skin skin) { setSkin(skin); setBackground(getSkin().getDrawable("panel_button_bg")); drawableMap.put(AttachmentPoint.AttachmentType.POSITION, getSkin().getDrawable("icon-target")); drawableMap.put(AttachmentPoint.AttachmentType.ROTATION, getSkin().getDrawable("icon-angle")); drawableMap.put(AttachmentPoint.AttachmentType.TRANSPARENCY, getSkin().getDrawable("icon-transparency")); drawableMap.put(AttachmentPoint.AttachmentType.COLOR, getSkin().getDrawable("icon-color")); button = new ImageButton(drawableMap.get(AttachmentPoint.AttachmentType.POSITION)); addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { currentType = currentType.next(); setButtonDrawable(); } }); setButtonDrawable(); }
Example #10
Source File: CalibrationScreen.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Adds exit button with listener in right bottom corner */ private void createBackButton() { // Create Button backButton = new TextButton("EXIT", VisUI.getSkin()); // Set position in bottom right corner backButton.setX(Gdx.graphics.getWidth()-60); backButton.setY(0); backButton.setWidth(60); backButton.setHeight(60); backButton.setVisible(true); // Add Listener that sets the screen to the start screen of the game when button is clicked backButton.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y) { StandardizedInterface.getInstance().StimuliSystem.stopStimulus(); frameCounter = 0; game.setScreen(new MainMenuScreen(game)); } }); // Add Button to stage stage.addActor(backButton); }
Example #11
Source File: ScnWidgetInputListener.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
@Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); // EditorLogger.debug("Touch Up - X: " + x + " Y: " + y); if (draggingMode == DraggingModes.DRAGGING_ACTOR) { Ctx.project.getUndoStack().add(new UndoPosition(selActor, new Vector2(undoOrg))); } else if (draggingMode == DraggingModes.ROTATE_ACTOR) { Ctx.project.getUndoStack().add(new UndoRotation((SpriteActor) selActor, undoRot)); } else if (draggingMode == DraggingModes.SCALE_ACTOR || draggingMode == DraggingModes.SCALE_LOCK_ACTOR) { Ctx.project.getUndoStack().add(new UndoScale((SpriteActor) selActor, new Vector2(undoOrg))); } else if (draggingMode == DraggingModes.DRAGGING_REFPOINT) { Ctx.project.getUndoStack().add(new UndoRefPosition((InteractiveActor) selActor, new Vector2(undoOrg))); } else if (draggingMode == DraggingModes.DRAGGING_BBOX_POINT) { Ctx.project.getUndoStack().add(new UndoBboxPointPos(selActor, vertIndex, new Vector2(undoOrg))); } else if (draggingMode == DraggingModes.DRAGGING_MARKER_0 || draggingMode == DraggingModes.DRAGGING_MARKER_100) { Ctx.project.getUndoStack().add(new UndoDepthVector(scnWidget.getScene(), new Vector2(undoOrg))); } draggingMode = DraggingModes.NONE; return; }
Example #12
Source File: Dialogs.java From vis-ui with Apache License 2.0 | 6 votes |
/** * Dialog with given text and single OK button. * @param title dialog title */ public static VisDialog showOKDialog (Stage stage, String title, String text) { final VisDialog dialog = new VisDialog(title); dialog.closeOnEscape(); dialog.text(text); dialog.button(ButtonType.OK.getText()).padBottom(3); dialog.pack(); dialog.centerWindow(); dialog.addListener(new InputListener() { @Override public boolean keyDown (InputEvent event, int keycode) { if (keycode == Keys.ENTER) { dialog.fadeOut(); return true; } return false; } }); stage.addActor(dialog.fadeIn()); return dialog; }
Example #13
Source File: PlayerBattleHUD.java From Norii with Apache License 2.0 | 6 votes |
private void createActionUIs(Entity[] sortedUnits) { for (int i = 0; i < sortedUnits.length; i++) { if (sortedUnits[i].isPlayerUnit()) { final Entity entity = sortedUnits[i]; actionUIs[i] = new ActionsUI(entity); final ActionsUI actionui = actionUIs[i]; actionui.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } }); stage.addActor(actionui); } } }
Example #14
Source File: PlayerBattleHUD.java From Norii with Apache License 2.0 | 6 votes |
private void createStatusUIs(Entity[] sortedUnits) { for (int i = 0; i < sortedUnits.length; i++) { final Entity entity = sortedUnits[i]; statusUIs[i] = new StatusUI(entity); final StatusUI statusui = statusUIs[i]; statusui.addListener(new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } }); stage.addActor(statusui); } }
Example #15
Source File: TImage.java From cocos-ui-libgdx with Apache License 2.0 | 6 votes |
public TImage isButton() { clearListeners(); origonCenter(); addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); addAction(Actions.sequence(Actions.scaleTo(0.9f, 0.9f, 0.1f), Actions.scaleTo(1, 1, 0.1f), Actions.run(new Runnable() { @Override public void run() { if (clickListener != null) { clickListener.onClicked(TImage.this); } } }))); } }); return this; }
Example #16
Source File: PatchGrid.java From gdx-texture-packer-gui with Apache License 2.0 | 6 votes |
@Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (button==0) { for (PatchLine patchLine : patchLines) { if (patchLine.hovered) { draggingLines.add(patchLine); patchLine.startDragging(x, y); } } if (draggingLines.size > 0) { event.handle(); event.stop(); return true; } } return false; }
Example #17
Source File: BasicColorPicker.java From vis-ui with Apache License 2.0 | 6 votes |
private VisTable createColorsPreviewTable () { VisTable table = new VisTable(false); table.add(currentColorImg = new AlphaImage(commons, 5 * sizes.scaleFactor)) .height(25 * sizes.scaleFactor).width(80 * sizes.scaleFactor).expandX().fillX(); table.add(new Image(style.iconArrowRight)).pad(0, 2, 0, 2); table.add(newColorImg = new AlphaImage(commons, 5 * sizes.scaleFactor)) .height(25 * sizes.scaleFactor).width(80 * sizes.scaleFactor).expandX().fillX(); currentColorImg.setColor(color); newColorImg.setColor(color); currentColorImg.addListener(new ClickListener() { @Override public void clicked (InputEvent event, float x, float y) { restoreLastColor(); } }); return table; }
Example #18
Source File: VisCheckBox.java From vis-ui with Apache License 2.0 | 6 votes |
public VisCheckBox (String text, VisCheckBoxStyle style) { super(text, style); clearChildren(); bgImage = new Image(style.checkBackground); tickImage = new Image(style.tick); imageStackCell = add(imageStack = new Stack(bgImage, tickImage)); Label label = getLabel(); add(label).padLeft(5); label.setAlignment(Align.left); setSize(getPrefWidth(), getPrefHeight()); addListener(new InputListener() { @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (isDisabled() == false) FocusManager.switchFocus(getStage(), VisCheckBox.this); return false; } }); }
Example #19
Source File: WorldSelectScreen.java From Unlucky with MIT License | 6 votes |
protected void handleEnterButton() { enterButtonGroup.setPosition(114, 4); stage.addActor(enterButtonGroup); enterLabel.setText("SELECT"); enterButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { if (!game.player.settings.muteSfx) rm.buttonclick0.play(game.player.settings.sfxVolume); if (clickable) { clickable = false; batchFade = false; // fade out animation stage.addAction(Actions.sequence(Actions.fadeOut(0.3f), Actions.run(new Runnable() { @Override public void run() { clickable = true; game.levelSelectScreen.setWorld(worldIndex); game.setScreen(game.levelSelectScreen); } }))); } } }); }
Example #20
Source File: SlotTooltipListener.java From Cubes with MIT License | 5 votes |
@Override public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { ItemStack stack = actor.getStack(); if (stack == null) return; inside = true; tooltip.setItemStack(stack); tooltip.setVisible(true); tmp.set(x, y); event.getListenerActor().localToStageCoordinates(tmp); tooltip.setPosition(tmp.x + position.x + offset.x, tmp.y + position.y + offset.y); tooltip.toFront(); }
Example #21
Source File: ResizeArrowListener.java From skin-composer with MIT License | 5 votes |
@Override public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) { if (!draggingCursor && event.getListenerActor().equals(event.getTarget())) { if (vertical) { Gdx.graphics.setSystemCursor(Cursor.SystemCursor.VerticalResize); } else { Gdx.graphics.setSystemCursor(Cursor.SystemCursor.HorizontalResize); } } }
Example #22
Source File: ResizeArrowListener.java From skin-composer with MIT License | 5 votes |
@Override public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { if (!draggingCursor && event.getListenerActor().equals(event.getTarget())) { Gdx.graphics.setSystemCursor(Cursor.SystemCursor.Arrow); } }
Example #23
Source File: PatchGrid.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
@Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { if (draggingLines.size > 0) { for (PatchLine patchLine : draggingLines) { patchLine.endDragging(x, y); } draggingLines.clear(); validateLinePositions(); updateModelFromLines(); } // Stage fires "exit" event upon touchUp() even if pointer is still over the actor. // This is simple workaround. if (hovered) ignoreNextExitEvent = true; }
Example #24
Source File: StyleSelectorPopTable.java From skin-composer with MIT License | 5 votes |
@Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); var stage = event.getListenerActor().getStage(); stage.setScrollFocus(scrollFocus); }
Example #25
Source File: TImage.java From cocos-ui-libgdx with Apache License 2.0 | 5 votes |
public TImage isNoButton() { clearListeners(); origonCenter(); addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { super.clicked(event, x, y); if (clickListener != null) { clickListener.onClicked(TImage.this); } } }); return this; }
Example #26
Source File: ControllerMenuStage.java From gdx-controllerutils with Apache License 2.0 | 5 votes |
/** * called on focusedActor when default action key is pressed or on escapeActor when escape key is pressed * * @param actor focusedActor or escapeActor * @return true if the event was handled */ protected boolean triggerActionOnActor(boolean keyDown, Actor actor) { if (actor instanceof IControllerActable && keyDown) return ((IControllerActable) actor).onControllerDefaultKeyDown(); else if (actor instanceof IControllerActable) return ((IControllerActable) actor).onControllerDefaultKeyUp(); else return fireEventOnActor(actor, keyDown ? InputEvent.Type.touchDown : InputEvent.Type.touchUp, 0, null); }
Example #27
Source File: ControllerMenuStage.java From gdx-controllerutils with Apache License 2.0 | 5 votes |
/** * fired when focus was lost, override for your own special actions * * @param focusedActor the actor that lost focus */ protected void onFocusLost(Actor focusedActor, Actor newFocused) { if (isPressed) { cancelTouchFocus(); isPressed = false; } if (sendMouseOverEvents) fireEventOnActor(focusedActor, InputEvent.Type.exit, -1, newFocused); }
Example #28
Source File: ControllerMenuStage.java From gdx-controllerutils with Apache License 2.0 | 5 votes |
/** * fired when focus was set, override for your own special actions * * @param focusedActor the actor that gained focus */ protected void onFocusGained(Actor focusedActor, Actor oldFocused) { if (sendMouseOverEvents) fireEventOnActor(focusedActor, InputEvent.Type.enter, -1, oldFocused); setKeyboardFocus(focusedActor); setScrollFocus(focusedActor); }
Example #29
Source File: CollapsableWindow.java From gdx-ai with Apache License 2.0 | 5 votes |
public CollapsableWindow (String title, Skin skin) { super(title, skin); addListener(new ClickListener() { @Override public void clicked (InputEvent event, float x, float y) { if (getTapCount() == 2 && getHeight() - y <= getPadTop() && y < getHeight() && x > 0 && x < getWidth()) toggleCollapsed(); } }); }
Example #30
Source File: NpcMenu.java From riiablo with Apache License 2.0 | 5 votes |
public NpcMenu addCancel(CancellationListener cancellationListener) { this.cancellationListener = cancellationListener; addItem(3400, new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { cancel(); menuManager.setMenu(parent, owner); } }); return this; }