/** Sets the cursor position and clears any selection. */ public void setCursorPosition (int cursorPosition) { if (cursorPosition < 0) throw new IllegalArgumentException("cursorPosition must be >= 0"); clearSelection(); cursor = Math.min(cursorPosition, text.length()); }
/** @param str If null, "" is used. */ public void appendText (String str) { if (str == null) str = ""; clearSelection(); cursor = text.length(); paste(str, programmaticChangeEvents); }
int delete (boolean fireChangeEvent) { int from = selectionStart; int to = cursor; int minIndex = Math.min(from, to); int maxIndex = Math.max(from, to); String newText = (minIndex > 0 ? text.substring(0, minIndex) : "") + (maxIndex < text.length() ? text.substring(maxIndex, text.length()) : ""); if (fireChangeEvent) changeText(text, newText); else text = newText; clearSelection(); return minIndex; }
/** Sets the selected text. */ public void setSelection (int selectionStart, int selectionEnd) { if (selectionStart < 0) throw new IllegalArgumentException("selectionStart must be >= 0"); if (selectionEnd < 0) throw new IllegalArgumentException("selectionEnd must be >= 0"); selectionStart = Math.min(text.length(), selectionStart); selectionEnd = Math.min(text.length(), selectionEnd); if (selectionEnd == selectionStart) { clearSelection(); return; } if (selectionEnd < selectionStart) { int temp = selectionEnd; selectionEnd = selectionStart; selectionStart = temp; } hasSelection = true; this.selectionStart = selectionStart; cursor = selectionEnd; }
/** @param str If null, "" is used. */ public void setText (String str) { if (str == null) str = ""; if (ignoreEqualsTextChange && str.equals(text)) return; clearSelection(); String oldText = text; text = ""; paste(str, false); if (programmaticChangeEvents) changeText(oldText, text); cursor = 0; }
@Override public void clicked (InputEvent event, float x, float y) { int count = getTapCount() % 4; if (count == 0) clearSelection(); if (count == 2) { int[] array = wordUnderCursor(x); setSelection(array[0], array[1]); } if (count == 3) selectAll(); }
clearSelection(); repeat = true; clearSelection(); repeat = true; clearSelection(); clearSelection();