|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.Field
net.rim.device.api.ui.component.TextField
net.rim.device.api.ui.component.BasicEditField
net.rim.device.api.ui.component.PasswordEditField
public class PasswordEditField
An editable text field designed specifically to handle password input.
Behaviour
This field stores the password as plain text but draws it as
a series of asterisks, one for each character cluster (group
of characters treated as one after diacritics and ligatures
have been handled).
This field does not have any automatic input replacement, so the typed text is exactly what is typed. AutoCaps, AutoText, AutoPeriod, and any other transformation are turned off. Also, holding a key and rolling the wheel is not allowed.
This field does not support copy or cut operations.
By default, this field supports all the available characters. You can restrict this by applying a TextFilter.
Field Summary |
---|
Fields inherited from class net.rim.device.api.ui.component.BasicEditField |
---|
FILTER_DEFAULT, FILTER_EMAIL, FILTER_FILENAME, FILTER_HEXADECIMAL, FILTER_INTEGER, FILTER_LOWERCASE, FILTER_NUMERIC, FILTER_PHONE, FILTER_PIN_ADDRESS, FILTER_REAL_NUMERIC, FILTER_UPPERCASE, FILTER_URL |
Fields inherited from class net.rim.device.api.ui.component.TextField |
---|
CONSUME_INPUT, DEFAULT_MAXCHARS, JUMP_FOCUS_AT_END, NO_COMPLEX_INPUT, NO_EDIT_MODE_INPUT, NO_LEARNING, NO_NEWLINE, NO_SWITCHING_INPUT |
Constructor Summary | ||
---|---|---|
PasswordEditField()
Constructs a new PasswordEditField instance. |
||
PasswordEditField(String label,
String initialValue)
Constructs a PasswordEditField instance with label and initial value. |
||
PasswordEditField(String label,
String initialValue,
int maxNumChars,
long style)
Constructs a smaller PasswordEditField object. |
Method Summary | ||
---|---|---|
protected boolean |
backspace()
Deletes character to the left of the cursor, or deletes selection. |
|
int |
backspace(int count)
Deletes specified number of characters to the left of the cursor. |
|
protected int |
backspace(int count,
int context)
Deletes specified number of characters to the left of the cursor, with indication of source of this action. |
|
char |
charAt(int offset)
Retrieves the character at the specified offset. |
|
void |
clear(int context)
Clears this field's contents. |
|
protected void |
displayFieldFullMessage()
Displays a 'field full' message. |
|
int |
getCursorPosition()
Retrieves character offset for current cursor position in this field. |
|
String |
getLabel()
Retrieves this field's label. |
|
int |
getLabelLength()
Retrieves the length of this field's label The length returned includes any additional character appended for layout purposes. |
|
int |
getMaxSize()
Retrieves the maximum number of characters allowed for this field's value. |
|
int |
getPreferredHeight()
Retrieves this field's preferred height. |
|
int |
getPreferredWidth()
Retrieves this field's preferred width. |
|
String |
getText()
Retrieves this field's text, not including the label. |
|
String |
getText(int offset,
int length)
Retrieves a portion of this field's text. |
|
void |
getText(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
Retrieves this field's text. |
|
AbstractString |
getTextAbstractString()
Retrieves read-only handle to the underlying buffer. |
|
int |
getTextLength()
Retrieves length of this field's text, not including the label. |
|
int |
insert(String text)
Inserts string programmatically into this field. |
|
protected int |
insert(String text,
int context)
Inserts string into this field. |
|
boolean |
isSelectionCopyable()
Determines if this field supports copy operations. |
|
protected boolean |
isSymbolScreenAllowed()
Determines if this field supports use of the symbol screen. |
|
protected boolean |
keyRepeat(int keycode,
int time)
Consumes key repeat events. |
|
protected void |
onUnfocus()
Invoked when a field loses the focus. |
|
boolean |
paste(Clipboard cb)
Pastes text scrap into this field. |
|
void |
selectionCopy(Clipboard cb)
Does nothing. |
|
void |
selectionDelete()
Deletes character to the right of the cursor, or deletes selection. |
|
void |
setCursorPosition(int offset)
Places cursor on specific character within this field, at user request. |
|
protected void |
setCursorPosition(int offset,
int context)
Places cursor on specific character within this field. |
|
void |
setLabel(String newLabel)
Sets this field's label. |
|
void |
setMaxSize(int maxSize)
Sets maximum number of characters allowed for this field's value. |
|
void |
setText(String text)
Sets the text value for this field. |
|
protected void |
setText(String text,
int context)
Sets the text value for this field, with indication of the source of this action. |
|
protected void |
update(int delta)
Updates this edit field. |
|
void |
wipe()
Overwrites this field's unused contents. |
Methods inherited from class net.rim.device.api.ui.component.BasicEditField |
---|
drawFocus, getAccessibleContext, getFilter, keyChar, keyControl, keyDown, layout, makeContextMenu, moveFocus, moveFocus, paint, setFilter, setFont |
Methods inherited from class net.rim.device.api.ui.component.TextField |
---|
drawText, fieldChangeNotify, getDescription, getFocusRect, getTrackpadScrollAmount, getTrackpadScrollLineSpeed, isPasteable, isSelectable, isSelecting, isSelectionDeleteable, keyStatus, navigationClick, navigationUnclick, onFocus, select, setDescription, toString, touchEvent |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.rim.device.api.im.ITextInputStyle |
---|
getPreferredInputLocale, getTextInputStyle, isEditable, isUnicodeInputAllowed, updateInputStyle |
Constructor Detail |
---|
public PasswordEditField()
This builds a new password edit field with no label and no initial contents.
public PasswordEditField(String label, String initialValue)
This method builds an editable password field that can hold up to
TextField.DEFAULT_MAXCHARS
characters.
Note that your provided text does not itself show up in the created field; this method shows a string of asterisks of the same length to the user.
label
- Label for this field.initialValue
- Initial password value for this field.public PasswordEditField(String label, String initialValue, int maxNumChars, long style)
This method builds an editable password field that can hold a number of characters up to the amount you specify.
Note that your provided text does not itself show up in the created field; this method shows a string of asterisks of the same length to the user.
label
- Label for this field.initialValue
- Initial password value for this field.maxNumChars
- Maximum number of characters this field can hold.style
- Style for this field: this value will be combined with the
EDITABLE
and NO_NEWLINE
styles.Method Detail |
---|
public final boolean isSelectionCopyable()
isSelectionCopyable
in class TextField
protected boolean keyRepeat(int keycode, int time)
This method consumes all key repeat events, which aren't appropriate for password fields except the speakerphone key when trackball is supported or media keys.
keyRepeat
in class Field
keycode
- Key being repeated (ignored).time
- Number of milliseconds since the device was turned on.
public final void selectionCopy(Clipboard cb)
This type of field does not support copy operations.
selectionCopy
in class TextField
cb
- Clipboard object.protected void onUnfocus()
BasicEditField
The method will not be invoked if this field does not already have the focus.
By default, this method clears the muddy bit and removes selection. If your custom field requires special handling upon losing the focus, you must override this method. Don't forget to call super.onUnFocus() though or the muddy bit won't get cleared.
onUnfocus
in class BasicEditField
protected boolean backspace()
TextField
If some characters are currently selected, this method deletes the selection as if it were a single character.
If no characters are selected, this method deletes the character immediately to the left of the cursor. If the cursor is currently on the first character in the field, this method does nothing.
backspace
in class BasicEditField
public int backspace(int count)
TextField
This method ignores the current selection and deletes a number of characters to the left of the current cursor position. If this method runs into the beginning of this field's editable value, it deletes as many characters as possible.
backspace
in class BasicEditField
count
- Number of characters to delete.
protected int backspace(int count, int context)
TextField
This method ignores the current selection and deletes a number of characters to the left of the current cursor position. If this method runs into the beginning of this field's editable value, it deletes as many characters as possible.
You can specify whether this method was invoked programmatically, or as an event prompted by the user.
backspace
in class BasicEditField
count
- Number of characters to delete.context
- Information specifying the origin of the change.
public char charAt(int offset)
TextField
Index zero is the first character position after this field's label.
charAt
in class BasicEditField
offset
- Index of the character to retrieve.
public void clear(int context)
TextField
Override this method if you want the default text to be non empty when the field is cleared. For example, a URLEditField might call setText("http://", context).
clear
in class BasicEditField
context
- Context ID for this action.public void wipe()
TextField
wipe
in class BasicEditField
public void selectionDelete()
TextField
If some characters are currently selected, this method deletes the selection as if they were a single character.
If no characters are selected, this method deletes the character immediately to the right of the cursor. If the cursor is currently on the last character in the field, this method does nothing.
selectionDelete
in class BasicEditField
TextField.isSelectionDeleteable()
,
Field.selectionCut(net.rim.device.api.system.Clipboard)
protected void displayFieldFullMessage()
TextField
displayFieldFullMessage
in class BasicEditField
public String getLabel()
TextField
getLabel
in class BasicEditField
public int getLabelLength()
TextField
The length returned includes any additional character appended for layout purposes.
Therefore the value may not be the same as #getLabel().length()
getLabelLength
in class BasicEditField
public int getMaxSize()
TextField
This method does not include this field's label as part of its accounting.
getMaxSize
in class BasicEditField
public int getPreferredHeight()
TextField
Managers make use of this value during layout. Edit fields determine their preferred height based on the height of the font they're using to display their text contents.
getPreferredHeight
in class BasicEditField
public int getPreferredWidth()
TextField
Managers make use of this value during layout. All editable fields to be as wide as possible. Non editable fields to be layed out with as little space as possible.
getPreferredWidth
in class BasicEditField
public String getText()
TextField
getText
in class BasicEditField
public String getText(int offset, int length)
TextField
Provide a character offset and length to retrieve a substring of this field's contents.
Note: This method includes the label in the field's contents, so if you pass in an offset of zero, the first character returned is the first character of the label.
Note: Different system themes may modify the contents of the label.
getText
in class BasicEditField
offset
- First character to return.length
- Number of characters to return; must be at least 1.
public void getText(int srcBegin, int srcEnd, char[] dst, int dstBegin)
TextField
Note: This method adjusts for the label in the field's
contents, so the srcBegin
and srcEnd
parameters describe the field's
actual contents.
getText
in class BasicEditField
srcBegin
- First character in source to retrieve.srcEnd
- Last character in source to retrieve; must be greater than srcBegin
.dst
- Character buffer to contain retrieved text.dstBegin
- Offset into buffer to receive the first retrieved
character.public AbstractString getTextAbstractString()
TextField
Note: The underlying buffer can be modified by this field if
methods such as TextField.insert(java.lang.String)
or TextField.selectionDelete()
are invoked.
getTextAbstractString
in class BasicEditField
public int getTextLength()
TextField
getTextLength
in class BasicEditField
public int insert(String text)
TextField
This method attempts to insert your specified string string at the current cursor position. If this method (even partially) succeeds with the insertion, it then moves the cursor to just after the last character successfully inserted.
If the maximum size of the field is exceeded while inserting the string, as many characters as possible are inserted.
Note: use this method for programmatic changes to this field;
be default, this method simply invokes
insert(yourString, FieldChangeListener.PROGRAMMATIC)
.
insert
in class BasicEditField
text
- String to insert.
protected int insert(String text, int context)
TextField
This method attempts to insert your specified string string at the current cursor position. If this method (even partially) succeeds with the insertion, it then moves the cursor to just after the last character successfully inserted.
If the maximum size of the field is exceeded while inserting the string, as many characters as possible are inserted.
insert
in class BasicEditField
text
- String to insert.context
- Information specifying the origin of the change. false
indicates user-initiated insertion.
protected boolean isSymbolScreenAllowed()
TextField
Use this method to determine if this field supports the symbol screen (all edit fields do by default). The user can press ALT+SPACE to show the symbol screen.
Subclasses may override this method to return different values depending on if they want the symbol screen to be allowed.
The implementation in this class unconditionally returns true
.
isSymbolScreenAllowed
in class BasicEditField
true
if this field supports the symbol screen;
false
if it does not.public void setLabel(String newLabel)
TextField
setLabel
in class BasicEditField
newLabel
- New label for this field.protected void update(int delta)
TextField
This field invokes this method when text is inserted or deleted so this field can update itself.
update
in class BasicEditField
delta
- Number of characters by which the field has changed,
negative or positive (negative means that characters have been
deleted).public void setMaxSize(int maxSize)
TextField
If this field currently holds more than your provided number, this method truncates this field's contents to fit.
This method does not include the label in its accounting.
setMaxSize
in class BasicEditField
maxSize
- New maximum number of characters for this edit field's value.public void setCursorPosition(int offset)
TextField
This method does not include the label as part of its accounting (that is, an offset of zero represents the first character in this field's text value).
This method assumes the repositioning request was user-initiated.
setCursorPosition
in class BasicEditField
offset
- Character position to receive the cursor, counting from the
first character in this field's value.protected void setCursorPosition(int offset, int context)
TextField
This method does not include the label as part of its accounting (that is, an offset of zero represents the first character in this field's text value).
setCursorPosition
in class BasicEditField
offset
- Character position to receive the cursor, counting from the
first character in this field's value.context
- Information specifying the origin of the change.public int getCursorPosition()
TextField
This method does not include the label as part of its accounting (that is, a returned offset of zero means that the cursor is currently sitting on the first character in this field's value).
getCursorPosition
in class BasicEditField
public boolean paste(Clipboard cb)
TextField
If this field is EDITABLE
, this method pastes the
scrap currently on the clipboard after the current cursor position.
This method attempts to insert as many characters as it can into this field. If this field's capacity is reached before all characters are pasted, then only those that fit are pasted.
If this field currently has some text selected, this method replaces the selection with the scrap from the clipboard.
paste
in class BasicEditField
cb
- Clipboard object holding the text scrap.
public void setText(String text) throws IllegalArgumentException
TextField
text
.
setText
in class BasicEditField
text
- New string value for this field; if null, this method clears
the field.
IllegalArgumentException
- If the text cannot be entered into an
edit field.protected void setText(String text, int context) throws IllegalArgumentException
TextField
setText
in class BasicEditField
text
- New string value for this field; if null, this method clears
the field.context
- Information specifying the origin of the change.
IllegalArgumentException
- If the text cannot be entered
into an edit field.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal