Java Code Examples for com.codename1.ui.TextArea#getCursorPosition()
The following examples show how to use
com.codename1.ui.TextArea#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: DefaultLookAndFeel.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
/** * Similar to getText() but works properly with password fields */ protected String getTextFieldString(TextArea ta) { String txt = ta.getText(); String text; if(ta.isSingleLineTextArea()){ text = txt; }else{ text = (String) ta.getTextAt(ta.getCursorY()); if(ta.getCursorPosition() + text.length() < txt.length()){ char c = txt.charAt(ta.getCursorPosition() + text.length()); if(c == '\n'){ text += "\n"; }else if(c == ' '){ text += " "; } } } String displayText = ""; if ((ta.getConstraint() & TextArea.PASSWORD) != 0) { // show the last character in a password field if (ta.isPendingCommit()) { if (text.length() > 0) { int tlen = text.length(); for (int j = 0; j < tlen - 1; j++) { displayText += passwordChar; } displayText += text.charAt(text.length() - 1); } } else { for (int j = 0; j < text.length(); j++) { displayText += passwordChar; } } } else { displayText = text; } return displayText; }