@Override public String toString () { return getText(); }
public String getText() { return textField.getText(); }
public String getPath() { return textField.getText(); }
public String getSuffix() { return edtSuffix.getText(); }
@Override public boolean acceptChar (VisTextField field, char c) { if (isAcceptNegativeValues()) { if (isUseFieldCursorPosition()) { if (c == '-' && (field.getCursorPosition() > 0 || field.getText().startsWith("-"))) return false; } else { if (c == '-' && field.getText().startsWith("-")) return false; } if (c == '-') return true; } return Character.isDigit(c); } }
@Override public boolean acceptChar (VisTextField field, char c) { int selectionStart = field.getSelectionStart(); int cursorPos = field.getCursorPosition(); String text; if (field.isTextSelected()) { //issue #131 String beforeSelection = field.getText().substring(0, Math.min(selectionStart, cursorPos)); String afterSelection = field.getText().substring(Math.max(selectionStart, cursorPos)); text = beforeSelection + afterSelection; } else { text = field.getText(); } if (c == '.' && text.contains(".") == false) return true; return super.acceptChar(field, c); } }
public void pathFieldKeyTyped (Stage stage, float width) { if (pathField.getText().length() == 0) { remove(); return; } createDirSuggestions(stage, width); }
@LmlAction("onFilePrefixTextChanged") void onFilePrefixFocusChanged() { inputFile.setDirFilePrefix(edtFilePrefix.getText().trim()); }
@LmlAction("onRegionNameTextChanged") void onRegionNameTextChanged() { inputFile.setRegionName(edtRegionName.getText().trim()); }
@Override public void changed (ChangeEvent event, Actor actor) { listener.finished(field.getText()); fadeOut(); } });
public void setCursorAtTextEnd () { setCursorPosition(0); calculateOffsets(); setCursorPosition(getText().length()); }
@LmlAction("onApiKeyChanged") void onApiKeyChanged() { tinifyService.setApiKey(edtApiKey.getText()); }
public void pathFieldKeyTyped (Stage stage, Array<FileHandle> files, VisTextField pathField) { if (pathField.getText().length() == 0) { remove(); return; } int suggestions = createSuggestions(files, pathField); if (suggestions == 0) { remove(); return; } showMenu(stage, pathField); }
@LmlAction("onPackFilenameTextChanged") void onPackFilenameTextChanged(VisTextField textField) { if (getSelectedPack() == null) return; final String text = textField.getText(); final PackModel pack = getSelectedPack(); Gdx.app.postRunnable(new Runnable() { @Override public void run() { pack.setFilename(text); } }); }
@Override public boolean keyDown (InputEvent event, int keycode) { if (keycode == Keys.ENTER && okButton.isDisabled() == false) { listener.finished(field.getText()); fadeOut(); } return super.keyDown(event, keycode); } });
@Override public void changed (ChangeEvent event, Actor actor) { deselectAll(false); fileNameSuggestionPopup.pathFieldKeyTyped(getChooserStage(), currentFiles, selectedFileTextField); FileHandle enteredFile = currentDirectory.child(selectedFileTextField.getText()); if (currentFiles.contains(enteredFile, false)) { highlightFiles(enteredFile); } } });
@LmlAction("launchUnpackProcess") void launchUnpackProcess() { try { Gdx.app.log(TAG, "Start texture unpacking"); FileHandle outputDir = Gdx.files.absolute(edtOutputDir.getText()); FileHandle atlasFile = FileUtils.obtainIfExists(edtAtlasPath.getText()); if (atlasFile == null) throw new IllegalStateException("Atlas file does not exist: " + edtAtlasPath.getText()); TextureAtlas.TextureAtlasData atlasData = new TextureAtlas.TextureAtlasData(atlasFile, atlasFile.parent(), false); TextureUnpacker textureUnpacker = new TextureUnpacker(); textureUnpacker.splitAtlas(atlasData, outputDir.path()); Gdx.app.log(TAG, "Texture unpacking successfully finished"); showSuccessfulDialog(outputDir); } catch (Exception e) { Gdx.app.log(TAG, "Texture unpacking failed with error", e); showErrorDialog(e); } }
@LmlAction("pickOutputDir") void pickOutputDir() { FileHandle dir = FileUtils.obtainIfExists(edtOutputDir.getText()); if (dir == null && FileUtils.fileExists(edtAtlasPath.getText())) { dir = FileUtils.obtainIfExists(edtAtlasPath.getText()).parent(); } FileChooser fileChooser = new FileChooser(dir, FileChooser.Mode.OPEN); fileChooser.setIconProvider(new AppIconProvider(fileChooser)); fileChooser.setSelectionMode(FileChooser.SelectionMode.DIRECTORIES); fileChooser.setListener(new FileChooserAdapter() { @Override public void selected (Array<FileHandle> file) { FileHandle chosenFile = file.first(); edtOutputDir.setText(chosenFile.path()); } }); stage.addActor(fileChooser.fadeIn()); }
@Override public boolean keyDown (InputEvent event, int keycode) { if (keycode == Keys.ENTER) { FileHandle file = Gdx.files.absolute(currentPath.getText()); if (file.exists()) { if (file.isDirectory() == false) file = file.parent(); setDirectory(file, HistoryPolicy.ADD); addRecentDirectory(file); } else { showDialog(POPUP_DIRECTORY_DOES_NOT_EXIST.get()); setCurrentPathFieldText(currentDirectory.path()); } event.stop(); } return false; } });
@LmlAction("pickAtlasPath") void pickAtlasPath() { FileHandle dir = FileUtils.obtainIfExists(edtAtlasPath.getText()); final FileChooser fileChooser = new FileChooser(dir, FileChooser.Mode.OPEN); fileChooser.setIconProvider(new AppIconProvider(fileChooser)); fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES); fileChooser.setFileTypeFilter(new FileUtils.FileTypeFilterBuilder(true) .rule("Texture atlas (*.json;*.pack;*.atlas)", "json", "pack", "atlas").get()); fileChooser.setListener(new FileChooserAdapter() { @Override public void selected (Array<FileHandle> file) { FileHandle chosenFile = file.first(); edtAtlasPath.setText(chosenFile.path()); } }); stage.addActor(fileChooser.fadeIn()); }