Java Code Examples for com.kotcrab.vis.ui.widget.VisTextField#getCursorPosition()
The following examples show how to use
com.kotcrab.vis.ui.widget.VisTextField#getCursorPosition() .
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: FloatDigitsOnlyFilter.java From vis-ui with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: IntDigitsOnlyFilter.java From vis-ui with Apache License 2.0 | 5 votes |
@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); }