\r
Stage stage = getStage();\r
if (stage != null && stage.getKeyboardFocus() == TextField.this) {\r
- if (character == BACKSPACE && (cursor > 0 || hasSelection)) {\r
- if (!hasSelection) {\r
- text = text.substring(0, cursor - 1) + text.substring(cursor);\r
- updateDisplayText();\r
- cursor--;\r
- renderOffset = 0;\r
- } else {\r
- delete();\r
+ if (character == BACKSPACE) {\r
+ if (cursor > 0 || hasSelection) {\r
+ if (!hasSelection) {\r
+ text = text.substring(0, cursor - 1) + text.substring(cursor);\r
+ updateDisplayText();\r
+ cursor--;\r
+ renderOffset = 0;\r
+ } else {\r
+ delete();\r
+ }\r
}\r
- }\r
- if (character == DELETE) {\r
+ } else if (character == DELETE) {\r
if (cursor < text.length() || hasSelection) {\r
if (!hasSelection) {\r
text = text.substring(0, cursor) + text.substring(cursor + 1);\r
delete();\r
}\r
}\r
- }\r
- if (character != ENTER_DESKTOP && character != ENTER_ANDROID) {\r
- if (filter != null && !filter.acceptChar(TextField.this, character)) return true;\r
- }\r
- if ((character == TAB || character == ENTER_ANDROID) && focusTraversal)\r
+ } else if ((character == TAB || character == ENTER_ANDROID) && focusTraversal) {\r
next(Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT));\r
- if (font.containsCharacter(character)) {\r
- if (maxLength > 0 && text.length() + 1 > maxLength) {\r
- return true;\r
+ } else if (font.containsCharacter(character)) {\r
+ // Character may be added to the text.\r
+ if (character != ENTER_DESKTOP && character != ENTER_ANDROID) {\r
+ if (filter != null && !filter.acceptChar(TextField.this, character)) return true;\r
}\r
+ if (maxLength > 0 && text.length() + 1 > maxLength) return true;\r
if (!hasSelection) {\r
text = text.substring(0, cursor) + character + text.substring(cursor, text.length());\r
updateDisplayText();\r