com.badlogic.gdx.scenes.scene2d.utils.UIUtils Java Examples
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.utils.UIUtils.
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: SceneGestureDetector.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
@Override public boolean keyUp(int keycode) { switch (keycode) { case Input.Keys.ESCAPE: case Input.Keys.BACK: case Input.Keys.MENU: dsc.showMenu(); break; case Input.Keys.D: if (UIUtils.ctrl()) EngineLogger.toggle(); break; case Input.Keys.SPACE: if (dsc.getDrawHotspots()) dsc.setDrawHotspots(false); break; } return true; }
Example #2
Source File: ScnWidgetInputListener.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
@Override public void clicked(InputEvent event, float x, float y) { Scene scn = scnWidget.getScene(); if (scn == null) return; Vector2 p = new Vector2(Gdx.input.getX(), Gdx.input.getY()); scnWidget.screenToWorldCoords(p); // DOUBLE CLICK TO CREATE OR DELETE POINTS if (getTapCount() == 2 && scnWidget.getSelectedActor() != null) { Polygon poly = scnWidget.getSelectedActor().getBBox(); if ((!(scnWidget.getSelectedActor() instanceof SpriteActor) || !((SpriteActor) scnWidget.getSelectedActor()).isBboxFromRenderer()) && !(scnWidget.getSelectedActor() instanceof AnchorActor)) { if (UIUtils.ctrl()) { // Delete the point if selected boolean deleted = PolygonUtils.deletePoint(poly, p.x, p.y, CanvasDrawer.CORNER_DIST); if (deleted) { Ctx.project.setModified(); return; } } else { boolean created = PolygonUtils.addClampPointIfTolerance(poly, p.x, p.y, CanvasDrawer.CORNER_DIST); if (created) { Ctx.project.setModified(); return; } } } } }
Example #3
Source File: AbstractListAdapter.java From vis-ui with Apache License 2.0 | 4 votes |
private boolean isMultiSelectKeyPressed () { if (multiSelectKey == DEFAULT_KEY) return UIUtils.ctrl(); else return Gdx.input.isKeyPressed(multiSelectKey); }
Example #4
Source File: AbstractListAdapter.java From vis-ui with Apache License 2.0 | 4 votes |
private boolean isGroupMultiSelectKeyPressed () { if (groupMultiSelectKey == DEFAULT_KEY) return UIUtils.shift(); else return Gdx.input.isKeyPressed(groupMultiSelectKey); }
Example #5
Source File: VisTextField.java From vis-ui with Apache License 2.0 | 4 votes |
@Override public boolean keyTyped (InputEvent event, char character) { if (disabled || readOnly) return false; // Disallow "typing" most ASCII control characters, which would show up as a space when onlyFontChars is true. switch (character) { case BACKSPACE: case TAB: case ENTER_ANDROID: case ENTER_DESKTOP: break; default: if (character < 32) return false; } Stage stage = getStage(); if (stage == null || stage.getKeyboardFocus() != VisTextField.this) return false; if (UIUtils.isMac && Gdx.input.isKeyPressed(Keys.SYM)) return true; if (focusTraversal && (character == TAB || (character == ENTER_ANDROID && enterKeyFocusTraversal))) { next(UIUtils.shift()); } else { boolean delete = character == DELETE; boolean backspace = character == BACKSPACE; boolean enter = character == ENTER_DESKTOP || character == ENTER_ANDROID; boolean add = enter ? writeEnters : (!onlyFontChars || style.font.getData().hasGlyph(character)); boolean remove = backspace || delete; if (add || remove) { String oldText = text; int oldCursor = cursor; if (hasSelection) cursor = delete(false); else { if (backspace && cursor > 0) { text = text.substring(0, cursor - 1) + text.substring(cursor--); renderOffset = 0; } if (delete && cursor < text.length()) { text = text.substring(0, cursor) + text.substring(cursor + 1); } } if (add && !remove) { // Character may be added to the text. if (!enter && filter != null && !filter.acceptChar(VisTextField.this, character)) return true; if (!withinMaxLength(text.length())) return true; String insertion = enter ? "\n" : String.valueOf(character); text = insert(cursor++, insertion, text); } if (changeText(oldText, text)) { long time = System.currentTimeMillis(); if (time - 750 > lastChangeTime) { undoText = oldText; undoCursorPos = getCursorPosition() - 1; } lastChangeTime = time; } else cursor = oldCursor; updateDisplayText(); } } if (listener != null) listener.keyTyped(VisTextField.this, character); return true; }
Example #6
Source File: VisTextArea.java From vis-ui with Apache License 2.0 | 4 votes |
@Override public boolean keyDown (InputEvent event, int keycode) { boolean result = super.keyDown(event, keycode); Stage stage = getStage(); if (stage != null && stage.getKeyboardFocus() == VisTextArea.this) { boolean repeat = false; boolean shift = UIUtils.shift(); if (keycode == Input.Keys.DOWN) { if (shift) { if (!hasSelection) { selectionStart = cursor; hasSelection = true; } } else { clearSelection(); } moveCursorLine(cursorLine + 1); repeat = true; } else if (keycode == Input.Keys.UP) { if (shift) { if (!hasSelection) { selectionStart = cursor; hasSelection = true; } } else { clearSelection(); } moveCursorLine(cursorLine - 1); repeat = true; } else { moveOffset = -1; } if (repeat) { scheduleKeyRepeatTask(keycode); } showCursor(); return true; } return result; }
Example #7
Source File: ScnWidgetInputListener.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
@Override public boolean keyDown(InputEvent event, int keycode) { super.keyDown(event, keycode); Polygon p = null; if (scnWidget.getStage() == null || scnWidget.getStage().getKeyboardFocus() != scnWidget) return false; switch (keycode) { case Keys.ENTER: break; case Keys.BACKSPACE: break; case Keys.Z: if (UIUtils.ctrl()) { Ctx.project.getUndoStack().undo(); } break; case Keys.FORWARD_DEL: BaseActor a = Ctx.project.getSelectedActor(); if (a == null) return false; Ctx.project.getUndoStack().add(new UndoDeleteActor(Ctx.project.getSelectedScene(), a)); Ctx.project.getSelectedScene().removeActor(a); Ctx.project.setModified(this, Project.NOTIFY_ELEMENT_DELETED, null, a); break; case Keys.S: if (UIUtils.ctrl()) { try { Ctx.project.saveProject(); } catch (IOException e1) { String msg = "Something went wrong while saving the actor.\n\n" + e1.getClass().getSimpleName() + " - " + e1.getMessage(); Message.showMsgDialog(scnWidget.getStage(), "Error", msg); EditorLogger.printStackTrace(e1); } } break; case Keys.UP: case Keys.DOWN: case Keys.LEFT: case Keys.RIGHT: selActor = scnWidget.getSelectedActor(); p = selActor.getBBox(); undoOrg.set(p.getX(), p.getY()); Ctx.project.setModified(this, Project.POSITION_PROPERTY, null, selActor); break; case Keys.PLUS: case 70: scnWidget.zoom(-1); break; case Keys.MINUS: scnWidget.zoom(1); break; } return false; }