Java 类com.badlogic.gdx.scenes.scene2d.utils.UIUtils 实例源码

项目:bladecoder-adventure-engine    文件:DefaultSceneScreen.java   
@Override
public boolean keyUp(int keycode) {
    switch (keycode) {
    case Input.Keys.ESCAPE:
    case Input.Keys.BACK:
    case Input.Keys.MENU:
        showMenu();
        break;
    case Input.Keys.D:
        if (UIUtils.ctrl())
            EngineLogger.toggle();
        break;
    case Input.Keys.SPACE:
        if (drawHotspots)
            drawHotspots = false;
        break;
    }

    return true;
}
项目:ead    文件:DefaultGameView.java   
private void initKeyboardListener() {
    addListener(new InputListener() {
        final ComponentMapper<KeyPressedComponent> keyPressed = ComponentMapper
                .getFor(KeyPressedComponent.class);

        public boolean keyDown(InputEvent event, int keycode) {
            EngineEntity entity = getLayer(Layer.SCENE);
            if (!keyPressed.has(entity)) {
                entity.add(gameLoop
                        .createComponent(KeyPressedComponent.class));
            }
            KeyPressedComponent keyPressedComponent = entity
                    .getComponent(KeyPressedComponent.class);
            RuntimeKey runtimeKeyEvent = Pools.obtain(RuntimeKey.class);
            runtimeKeyEvent.setKeycode(keycode);
            runtimeKeyEvent.setAlt(UIUtils.alt());
            runtimeKeyEvent.setCtrl(UIUtils.ctrl());
            runtimeKeyEvent.setShift(UIUtils.shift());
            keyPressedComponent.getKeyEvents().add(runtimeKeyEvent);
            return true;
        }
    });

}
项目:ead    文件:ShortcutsMap.java   
/**
 * Fire the shortcut of the given code. Ctrl/Command, alt and shift are
 * automatically added by the method.
 * 
 * @return if a shortcutr was fired
 */
public boolean shortcut(int keycode) {
    tempShortcut.ctrl = UIUtils.ctrl();
    tempShortcut.alt = UIUtils.alt();
    tempShortcut.shift = UIUtils.shift();
    tempShortcut.keycode = keycode;

    Gdx.app.debug("ShortcutsMap", "Shortcut: " + tempShortcut);

    ShortcutAction a = shortcuts.get(tempShortcut);
    if (a != null) {
        controller.action(a.action, a.args);
        return true;
    }
    return false;
}
项目:vis-editor    文件:ExportersManagerModule.java   
@Override
public boolean keyDown (InputEvent event, int keycode) {
    if (UIUtils.ctrl() && keycode == Keys.E) {
        export(false);
        return true;
    }

    return false;
}
项目:vis-editor    文件:BaseSelectionTool.java   
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
    if (button == Buttons.LEFT) {
        x = camera.getInputX();
        y = camera.getInputY();

        dragging = true;

        lastTouchX = x;
        lastTouchY = y;

        dragStartX = x;
        dragStartY = y;

        if (isMouseInsideSelectedEntities(x, y) == false) {
            mouseInsideSelected = true;

            //multiple select made easy
            if (UIUtils.ctrl() == false) entityManipulator.softSelectionReset();

            EntityProxy result = findEntityWithSmallestSurfaceArea(x, y);
            if (result != null && entityManipulator.isSelected(result) == false)
                entityManipulator.selectAppend(result);
            else
                return rectangularSelection.touchDown(x, y, button);

            return true;
        }

    }

    return false;
}
项目:vis-editor    文件:UndoModule.java   
@Override
public boolean keyDown (InputEvent event, int keycode) {
    if (tabActive) {
        if (UIUtils.ctrl()) {
            if (keycode == Keys.Z) undo();
            if (keycode == Keys.Y) redo();

            return true;
        }
    }

    return false;
}
项目:vis-editor    文件:EditingSettingsModule.java   
@Override
public boolean keyDown (InputEvent event, int keycode) {
    if (UIUtils.shift() && keycode == Keys.NUM_5) {
        App.eventBus.post(new ToggleToolbarEvent(ToolbarEventType.GRID_SNAP_SETTING_CHANGED, !isSnapToGrid()));
        return true;
    }

    return false;
}
项目:vis-editor    文件:NumberInputField.java   
@Override
public boolean keyDown (InputEvent event, int keycode) {
    repeatTask.cancel();

    int delta = 0;
    if (UIUtils.ctrl()) delta = 1;
    if (UIUtils.shift()) delta = 10;

    if (delta != 0) {
        if (keycode == Keys.MINUS) {
            changeFieldValue(delta * -1);

            if (repeatTask.isScheduled() == false || repeatTask.valueDelta != delta) {
                repeatTask.valueDelta = delta * -1;
                repeatTask.cancel();
                Timer.schedule(repeatTask, 0.2f, 0.2f);
                return false;
            }

            return false;
        }
        if (keycode == Keys.PLUS) {
            changeFieldValue(delta);

            if (repeatTask.isScheduled() == false || repeatTask.valueDelta != delta) {
                repeatTask.valueDelta = delta;
                repeatTask.cancel();
                Timer.schedule(repeatTask, 0.2f, 0.2f);
                return false;
            }

            return false;
        }

    }

    return super.keyDown(event, keycode);
}
项目:vis-editor    文件:NumberInputField.java   
@Override
public boolean acceptChar (VisTextField field, char c) {
    if (c == '.' && field.getText().contains(".")) return false;
    if (field.getCursorPosition() > 0 && c == '-' && UIUtils.shift() == false && UIUtils.ctrl() == false)
        return false;
    if (field.getText().startsWith("-") && c == '-') return false;

    if (c == '-' || c == '?') return true;
    if (c == '.') return floatInput;
    if (c == '+') return false;

    return Character.isDigit(c);
}
项目:ead    文件:UITest.java   
@Override
public boolean keyUp(InputEvent event, int keycode) {
    switch (keycode) {
    case Keys.ESCAPE:
        if (UIUtils.ctrl()) {
            controller.action(Exit.class);
        }
        break;
    case Keys.O:
        if (UIUtils.ctrl()) {
            controller.action(OpenGame.class);
        }
        break;
    case Keys.S:
        if (UIUtils.ctrl()) {
            controller.action(ForceSave.class);
        }
        break;
    case Keys.Z:
        if (UIUtils.ctrl()) {
            controller.action(Undo.class);
        }
        break;
    case Keys.Y:
        if (UIUtils.ctrl()) {
            controller.action(Redo.class);
        }
        break;
    case Keys.Q:
        if (UIUtils.ctrl()) {
            nextScene();
        }
        break;
    }
    return super.keyUp(event, keycode);
}
项目:libgdxcn    文件:TextField.java   
public boolean keyTyped (InputEvent event, char character) {
    if (disabled) return false;
    if (character == 0) return false;

    Stage stage = getStage();
    if (stage == null || stage.getKeyboardFocus() != TextField.this) return false;

    if ((character == TAB || character == ENTER_ANDROID) && focusTraversal) {
        next(UIUtils.shift());
    } else {
        boolean delete = character == DELETE;
        boolean backspace = character == BACKSPACE;
        boolean add = style.font.containsCharacter(character)
            || (writeEnters && (character == ENTER_ANDROID || character == ENTER_DESKTOP));
        boolean remove = backspace || delete;
        if (add || remove) {
            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.
                boolean isEnter = character == ENTER_DESKTOP || character == ENTER_ANDROID;
                if (!isEnter) {
                    if (filter != null && !filter.acceptChar(TextField.this, character)) return true;
                }
                if (!withinMaxLength(text.length())) return true;
                String insertion = isEnter ? "\n" : String.valueOf(character);
                text = insert(cursor++, insertion, text);
            }
            updateDisplayText();
        }
    }
    if (listener != null) listener.keyTyped(TextField.this, character);
    return true;
}
项目:gaiasky    文件:TextField.java   
public boolean keyTyped(InputEvent event, char character) {
    if (disabled)
        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() != TextField.this)
        return false;

    if (UIUtils.isMac && Gdx.input.isKeyPressed(Keys.SYM))
        return true;

    if ((character == TAB || character == ENTER_ANDROID) && focusTraversal) {
        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(TextField.this, character))
                    return true;
                if (!withinMaxLength(text.length()))
                    return true;
                String insertion = enter ? "\n" : String.valueOf(character);
                text = insert(cursor++, insertion, text);
            }
            String tempUndoText = undoText;
            if (changeText(oldText, text)) {
                long time = System.currentTimeMillis();
                if (time - 750 > lastChangeTime)
                    undoText = oldText;
                lastChangeTime = time;
            } else
                cursor = oldCursor;
            updateDisplayText();
        }
    }
    if (listener != null)
        listener.keyTyped(TextField.this, character);
    return true;
}
项目:bladecoder-adventure-engine    文件:ScnWidgetInputListener.java   
@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;
}
项目:vis-editor    文件:AbstractListAdapter.java   
private boolean isMultiSelectKeyPressed () {
    if (multiSelectKey == DEFAULT_KEY)
        return UIUtils.ctrl();
    else
        return Gdx.input.isKeyPressed(multiSelectKey);
}
项目:vis-editor    文件:AbstractListAdapter.java   
private boolean isGroupMultiSelectKeyPressed () {
    if (groupMultiSelectKey == DEFAULT_KEY)
        return UIUtils.shift();
    else
        return Gdx.input.isKeyPressed(groupMultiSelectKey);
}
项目:vis-editor    文件:VisTextField.java   
@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;
}
项目:vis-editor    文件:VisTextArea.java   
@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;
}
项目:vis-editor    文件:EntityManipulatorModule.java   
@Override
public boolean keyDown (InputEvent event, int keycode) {
    if (UIUtils.ctrl() && keycode == Keys.S) sceneTab.save();
    if (keycode == Keys.F1) {
        switchTool(SelectionTool.TOOL_ID);
        App.eventBus.post(new ToolSwitchedEvent(SelectionTool.TOOL_ID));
    }
    if (keycode == Keys.F2) {
        switchTool(RotateTool.TOOL_ID);
        App.eventBus.post(new ToolSwitchedEvent(RotateTool.TOOL_ID));
    }
    if (keycode == Keys.F3) {
        switchTool(ScaleTool.TOOL_ID);
        App.eventBus.post(new ToolSwitchedEvent(ScaleTool.TOOL_ID));
    }
    if (keycode == Keys.F4) {
        switchTool(PolygonTool.TOOL_ID);
        App.eventBus.post(new ToolSwitchedEvent(PolygonTool.TOOL_ID));
    }

    if (scene.getActiveLayer().locked) return false;
    boolean result = currentTool.keyDown(event, keycode);

    if (result == false) {
        if (keycode == Keys.FORWARD_DEL) { //Delete
            deleteSelectedEntities();
            return true;
        }

        if (UIUtils.ctrl()) {
            if (keycode == Keys.A) selectAll();
            if (keycode == Keys.C) copy();
            if (keycode == Keys.V) paste();
            if (keycode == Keys.X) cut();
            if (keycode == Keys.D) duplicate();
        }

        if (Gdx.input.isKeyPressed(Keys.PAGE_UP))
            zIndexManipulator.moveSelectedEntities(getSelectedEntities(), true);
        if (Gdx.input.isKeyPressed(Keys.PAGE_DOWN))
            zIndexManipulator.moveSelectedEntities(getSelectedEntities(), false);

        return false;
    }

    return true;
}
项目:vis-editor    文件:EditingSettingsModule.java   
public boolean isSnapEnabledOrKeyPressed () {
    boolean snap = config.snapToGrid;
    if (UIUtils.ctrl()) snap = !snap; //allow to override snap setting
    return snap;
}
项目:vis-editor    文件:NumberInputField.java   
@Override
public boolean keyTyped (InputEvent event, char character) {
    if (character == '-' && UIUtils.shift()) return false;
    return super.keyTyped(event, character);
}
项目:ead    文件:EditorUITest.java   
@Override
public boolean keyUp(InputEvent event, int keycode) {
    switch (keycode) {
    case Keys.ESCAPE:
        if (UIUtils.ctrl()) {
            controller.action(Exit.class);
        }
        break;
    case Keys.O:
        if (UIUtils.ctrl()) {
            controller.action(OpenGame.class);
        }
        break;
    case Keys.S:
        if (UIUtils.ctrl()) {
            controller.action(Save.class);
        }
        break;
    case Keys.Z:
        if (UIUtils.ctrl()) {
            controller.action(Undo.class);
        }
        break;
    case Keys.Y:
        if (UIUtils.ctrl()) {
            controller.action(Redo.class);
        }
        break;
    case Keys.Q:
        if (UIUtils.ctrl()) {
            nextScene();
        }
        break;
    case Keys.A:
        if (UIUtils.ctrl()) {
            addSceneElement();
        }
        break;
    }
    return super.keyUp(event, keycode);
}