Class TextFieldState
java.lang.Object
dev.boze.api.gui.util.TextFieldState
Text being typed: the text, a caret, a length limit and the characters the field accepts.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IntPredicateAny character that is not a control character. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidintcaret()voidclear()voiddelete()voidend()voidhome()booleaninsert(int codepoint) booleanInserts what the field accepts at the caret, up to its length limit.booleanisEmpty()booleankeyPressed(GuiKeyEvent event, Supplier<String> clipboard) Handles the editing keys every Boze text field takes: Backspace (with Ctrl or Cmd, everything before the caret), Delete, Left, Right, Home, End and paste.voidleft()intvoidright()voidReplaces the text without filtering it, with the caret at the end.text()
-
Field Details
-
PRINTABLE
Any character that is not a control character.
-
-
Constructor Details
-
TextFieldState
- Parameters:
maxLength- Most characters the field holdsallowed- Which code points can be typed or pasted
-
-
Method Details
-
text
-
isEmpty
public boolean isEmpty() -
caret
public int caret() -
maxLength
public int maxLength() -
setText
Replaces the text without filtering it, with the caret at the end. -
clear
public void clear() -
insert
Inserts what the field accepts at the caret, up to its length limit.- Returns:
- Whether anything was inserted
-
insert
public boolean insert(int codepoint) -
backspace
public void backspace() -
delete
public void delete() -
left
public void left() -
right
public void right() -
home
public void home() -
end
public void end() -
keyPressed
Handles the editing keys every Boze text field takes: Backspace (with Ctrl or Cmd, everything before the caret), Delete, Left, Right, Home, End and paste.- Parameters:
clipboard- Gives the clipboard text when pasting- Returns:
- Whether the key was used
-
beforeCaret
- Returns:
- Text before the caret
-
afterCaret
- Returns:
- Text after the caret
-