net.rim.device.api.ui.component
Class BasicEditField

java.lang.Object
  extended by net.rim.device.api.ui.Field
      extended by net.rim.device.api.ui.component.TextField
          extended by net.rim.device.api.ui.component.BasicEditField
All Implemented Interfaces:
ITextInputStyle
Direct Known Subclasses:
EditField, PasswordEditField

public class BasicEditField
extends TextField

An editable simple text field with no formatting.

Behaviour
Displays a label in front of the text contents. If the contents occupy more than one line the text will flow around the label. The caret position is behaves as if it were between characters in the text contents, however it appears as a full inverted box on the character immediately following the caret.

The trackwheel moves the focus caret in the major direction (usually vertical), and using alt+trackwheel will move the focus caret in a less significant direction (usually horizontal).

If this field is Field.EDITABLE, typing inserts text into the contents at the caret position. The BACKSPACE character removes the character prior to the caret, and the DELETE character removes the character after the caret. Some subclasses of this may choose to support special symbols: typing a Sym brings up the symbol screen from which the user can select a symbol. Depending on the keyboard Sym could alternatively be Alt+Space or Alt+ZX.

Select Mode
In select mode, the selection is first anchored to a caret position, and moving the caret selects the text between the caret and the anchor. The following table summarizes the keystroke behaviour in select mode.

keystroke action taken
backspace nothing
alt+backspace nothing
shift+backspace nothing
delete delete
alt+delete delete
shift+delete cut
escape exit selection mode
alt+click copy
shift+click paste
shift+scroll select word

When not in select mode, these keystrokes should provide cut and paste functionality:

keystroke action taken
alt+click enter select mode
shift+click paste
shift+roll enter select mode and select word


Field Summary
static long FILTER_DEFAULT
          A style that causes a default text input filter to be used.
static long FILTER_EMAIL
          A style that causes an email text input filter to be used.
static long FILTER_FILENAME
          A style that causes a Filename input filter to be used.
static long FILTER_HEXADECIMAL
          A style that causes a hexadecimal text input filter to be used.
static long FILTER_INTEGER
          A style that causes an integer text input filter to be used.
static long FILTER_LOWERCASE
          A style that causes a lower case text input filter to be used.
static long FILTER_NUMERIC
          A style that causes a numeric text input filter to be used.
static long FILTER_PHONE
          A style that causes a phone text input filter to be used.
static long FILTER_PIN_ADDRESS
          A style that causes a PIN address text input filter to be used.
static long FILTER_REAL_NUMERIC
          A style that causes a real numeric text input filter to be used.
static long FILTER_UPPERCASE
          A style that causes an upper case text input filter to be used.
static long FILTER_URL
          A style that causes a URL text input filter to be used.
 
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
 
Fields inherited from class net.rim.device.api.ui.Field
ACTION_INVOKE, AXIS_HORIZONTAL, AXIS_SEQUENTIAL, AXIS_VERTICAL, EDITABLE, EDITABLE_MASK, FIELD_BOTTOM, FIELD_HALIGN_MASK, FIELD_HCENTER, FIELD_LEADING, FIELD_LEFT, FIELD_RIGHT, FIELD_TOP, FIELD_TRAILING, FIELD_VALIGN_MASK, FIELD_VCENTER, FOCUSABLE, FOCUSABLE_MASK, HIGHLIGHT_FOCUS, HIGHLIGHT_SELECT, NON_FOCUSABLE, NON_SPELLCHECKABLE, READONLY, SPELLCHECKABLE, SPELLCHECKABLE_MASK, STATUS_MOVE_FOCUS_HORIZONTALLY, STATUS_MOVE_FOCUS_VERTICALLY, USE_ALL_HEIGHT, USE_ALL_WIDTH, VISUAL_STATE_ACTIVE, VISUAL_STATE_DISABLED, VISUAL_STATE_DISABLED_FOCUS, VISUAL_STATE_FOCUS, VISUAL_STATE_NORMAL
 
Constructor Summary
BasicEditField()
          Constructs an empty BasicEditField instance.
BasicEditField(String label, String initialValue)
          Constructs an BasicEditField instance with label and initial contents.
BasicEditField(String label, String initialValue, int maxNumChars, long style)
          Constructs a smaller BasicEditField instance with label, initial contents, and particular style.
BasicEditField(long style)
          Constructs an empty BasicEditField instance of particular style.
 
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.
protected  void drawFocus(Graphics graphics, boolean on)
          Draws the focus indicator for this field.
 AccessibleContext getAccessibleContext()
          Accessibility.
 int getCursorPosition()
          Retrieves character offset for current cursor position in this field.
 TextFilter getFilter()
          Gets the text filter set for 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.
protected  boolean isSymbolScreenAllowed()
          Determines if this field supports use of the symbol screen.
protected  boolean keyChar(char key, int status, int time)
          Traps key generation events.
protected  boolean keyControl(char key, int status, int time)
          Handles control character generation events.
protected  boolean keyDown(int keycode, int time)
          Handles key-down events.
protected  void layout(int width, int height)
          Lays out this field's contents.
protected  void makeContextMenu(ContextMenu contextMenu)
          Builds this field's context menu.
protected  int moveFocus(int amount, int status, int time)
          Handles moving focus within this field.
protected  void moveFocus(int x, int y, int status, int time)
          Handles moving the focus to an exact position within this field.
protected  void onUnfocus()
          Invoked when a field loses the focus.
protected  void paint(Graphics graphics)
          Redraws this field.
 boolean paste(Clipboard cb)
          Pastes text scrap into this field.
 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 setFilter(TextFilter filter)
          Sets the text filter for this field.
 void setFont(Font font)
          Sets the font for this field and updates the display if necessary.
 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.TextField
drawText, fieldChangeNotify, getDescription, getFocusRect, getTrackpadScrollAmount, getTrackpadScrollLineSpeed, isPasteable, isSelectable, isSelecting, isSelectionCopyable, isSelectionDeleteable, keyStatus, navigationClick, navigationUnclick, onFocus, select, selectionCopy, setDescription, toString, touchEvent
 
Methods inherited from class net.rim.device.api.ui.Field
cursorClick, cursorUnclick, drawHighlightRegion, focusAdd, focusRemove, getBackground, getBackground, getBorder, getBorder, getBorder, getChangeListener, getCommandItemProvider, getContentHeight, getContentLeft, getContentRect, getContentRect, getContentTop, getContentWidth, getContextMenu, getCookie, getExtent, getExtent, getFieldStyle, getFocusListener, getFont, getHeight, getIndex, getLeafFieldWithFocus, getLeft, getManager, getMargin, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getOriginal, getPadding, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getScreen, getStyle, getTextFillColor, getTextStrokeColor, getTop, getVisualState, getWidth, invalidate, invalidate, invalidateAll, invokeAction, isDataValid, isDirty, isEditable, isEnabled, isFocus, isFocusable, isLeftToRight, isMuddy, isScrollCopyable, isSelectionCutable, isSpellCheckable, isStyle, isVisible, keyRepeat, keyUp, navigationMovement, onDisplay, onExposed, onMenuDismissed, onMenuDismissed, onObscured, onUndisplay, onVisibilityChange, selectionCut, setBackground, setBackground, setBorder, setBorder, setBorder, setBorder, setChangeListener, setCommandItemProvider, setCookie, setDirty, setEditable, setEnabled, setExtent, setFocus, setFocusListener, setFont, setMargin, setMargin, setMuddy, setNonSpellCheckable, setPadding, setPadding, setPosition, setVisualState, trackwheelClick, trackwheelUnclick, updateLayout
 
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
 



Field Detail

FILTER_DEFAULT

public static final long FILTER_DEFAULT
A style that causes a default text input filter to be used.

See Also:
Constant Field Values

FILTER_EMAIL

public static final long FILTER_EMAIL
A style that causes an email text input filter to be used.

Field accepts characters valid in an email address for input.

See Also:
Constant Field Values

FILTER_NUMERIC

public static final long FILTER_NUMERIC
A style that causes a numeric text input filter to be used. Accepts input of the form [0-9]*

In other words, it accepts any combination of numeric characters. This constant represents a style that enables a BasicEditField to use a TextFilter.NUMERIC object to filter text. This is equivalent to invoking this field's setFilter() method with a TextFilter.NUMERIC as the parameter.

See Also:
Constant Field Values

FILTER_REAL_NUMERIC

public static final long FILTER_REAL_NUMERIC
A style that causes a real numeric text input filter to be used. Accepts input of the form [-][0-9.]*

In other words, it accepts an optional minus sign, followed by any combination of numeric characters and periods.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.2

FILTER_UPPERCASE

public static final long FILTER_UPPERCASE
A style that causes an upper case text input filter to be used.

Field accepts only upper case alpha characters for input. Lower case characters are converted into their upper case equivalents.

See Also:
Constant Field Values

FILTER_LOWERCASE

public static final long FILTER_LOWERCASE
A style that causes a lower case text input filter to be used.

Field accepts only lower case alpha characters for input. Upper case are converted into their lower case equivalents.

See Also:
Constant Field Values

FILTER_HEXADECIMAL

public static final long FILTER_HEXADECIMAL
A style that causes a hexadecimal text input filter to be used.

Field accepts numeric characters and alpha characters a-f, A-F for input.

See Also:
Constant Field Values

FILTER_INTEGER

public static final long FILTER_INTEGER
A style that causes an integer text input filter to be used. Accepts input of the form [-][0-9]*

In other words, it accepts an optional minus sign, followed by any combination of numeric characters.

See Also:
Constant Field Values

FILTER_PHONE

public static final long FILTER_PHONE
A style that causes a phone text input filter to be used.

Field accepts numeric characters, the plus sign, minus sign, right and left parentheses, and the x character, for input.

See Also:
Constant Field Values

FILTER_URL

public static final long FILTER_URL
A style that causes a URL text input filter to be used.

Field accepts characters valid in a URL for input.

See Also:
Constant Field Values

FILTER_PIN_ADDRESS

public static final long FILTER_PIN_ADDRESS
A style that causes a PIN address text input filter to be used.

Field accepts characters valid in a PIN address for input.

See Also:
Constant Field Values
Since:
BlackBerry API 4.0.0

FILTER_FILENAME

public static final long FILTER_FILENAME
A style that causes a Filename input filter to be used.

Field accepts characters valid in a filename for FAT16 filesystem.

See Also:
Constant Field Values
Since:
BlackBerry API 4.2.0


Constructor Detail

BasicEditField

public BasicEditField()
Constructs an empty BasicEditField instance.

This method builds an empty, Field.EDITABLE edit field that has no label and can hold up to TextField.DEFAULT_MAXCHARS characters.


BasicEditField

public BasicEditField(long style)
Constructs an empty BasicEditField instance of particular style.

This method builds an empty edit field with a style that has no label and can hold up to TextField.DEFAULT_MAXCHARS characters.

Parameters:
style - Styles for this field (see Field for usable styles).

BasicEditField

public BasicEditField(String label,
                      String initialValue)
Constructs an BasicEditField instance with label and initial contents.

This method builds an Field.EDITABLE edit field with a specified label and initial contents that can hold up to TextField.DEFAULT_MAXCHARS characters.

Parameters:
label - Label for this field.
initialValue - Initial text to show in this field.

BasicEditField

public BasicEditField(String label,
                      String initialValue,
                      int maxNumChars,
                      long style)
Constructs a smaller BasicEditField instance with label, initial contents, and particular style.

This class's other constructors build an Field.EDITABLE field by default. Use this method to build an edit field with some other style.

Parameters:
label - Label for this field.
initialValue - Initial text to show in the field.
maxNumChars - Maximum number of characters this field can hold.
style - Styles for this field (see Field for usable styles).
Throws:
IllegalArgumentException - If maxNumChars is less than 1, or the initialValue argument is invalid given the style.


Method Detail

onUnfocus

protected void onUnfocus()
Invoked when a field loses the focus.

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.

Overrides:
onUnfocus in class Field
Since:
BlackBerry API 3.7.0

makeContextMenu

protected void makeContextMenu(ContextMenu contextMenu)
Builds this field's context menu.

Field.getContextMenu() invokes this method to construct this field's context menu.

This method populates the context menu with cut, copy, paste, and clear selection entries, if appropriate (i.e., the field is Field.EDITABLE).

Overrides:
makeContextMenu in class TextField
Parameters:
contextMenu - The context menu to build.
See Also:
ContextMenu

backspace

protected boolean backspace()
Description copied from class: TextField
Deletes character to the left of the cursor, or deletes selection.

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.

Overrides:
backspace in class TextField
Returns:
True if this method successfully removed a character or selection; otherwise, false.

backspace

public int backspace(int count)
Description copied from class: TextField
Deletes specified number of characters to the left of the cursor.

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.

Overrides:
backspace in class TextField
Parameters:
count - Number of characters to delete.
Returns:
Number of characters actually deleted.

backspace

protected int backspace(int count,
                        int context)
Description copied from class: TextField
Deletes specified number of characters to the left of the cursor, with indication of source of this action.

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.

Overrides:
backspace in class TextField
Parameters:
count - Number of characters to delete.
context - Information specifying the origin of the change.
Returns:
Number of characters actually deleted.

charAt

public char charAt(int offset)
Description copied from class: TextField
Retrieves the character at the specified offset.

Index zero is the first character position after this field's label.

Overrides:
charAt in class TextField
Parameters:
offset - Index of the character to retrieve.
Returns:
Character at your specified offset.

clear

public void clear(int context)
Description copied from class: TextField
Clears this field's contents.

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).

Overrides:
clear in class TextField
Parameters:
context - Context ID for this action.

wipe

public void wipe()
Description copied from class: TextField
Overwrites this field's unused contents.

Overrides:
wipe in class TextField
Since:
BlackBerry API 4.0.0

selectionDelete

public void selectionDelete()
Description copied from class: TextField
Deletes character to the right of the cursor, or deletes selection.

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.

Overrides:
selectionDelete in class TextField
See Also:
TextField.isSelectionDeleteable(), Field.selectionCut(net.rim.device.api.system.Clipboard)

displayFieldFullMessage

protected void displayFieldFullMessage()
Description copied from class: TextField
Displays a 'field full' message.

Overrides:
displayFieldFullMessage in class TextField

getLabel

public String getLabel()
Description copied from class: TextField
Retrieves this field's label.

Overrides:
getLabel in class TextField
Returns:
This field's label, or null if this field has no label.

getLabelLength

public int getLabelLength()
Description copied from class: TextField
Retrieves the length of this field's label

The length returned includes any additional character appended for layout purposes. Therefore the value may not be the same as #getLabel().length()

Overrides:
getLabelLength in class TextField
Returns:
Length of this field's label string and any additional layout character.

getMaxSize

public int getMaxSize()
Description copied from class: TextField
Retrieves the maximum number of characters allowed for this field's value.

This method does not include this field's label as part of its accounting.

Overrides:
getMaxSize in class TextField
Returns:
Maximum number of characters allowed in this edit field.

getPreferredHeight

public int getPreferredHeight()
Description copied from class: TextField
Retrieves this field's preferred height.

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.

Overrides:
getPreferredHeight in class TextField
Returns:
Preferred height for this field (height of current font).

getPreferredWidth

public int getPreferredWidth()
Description copied from class: TextField
Retrieves this field's preferred width.

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.

Overrides:
getPreferredWidth in class TextField
Returns:
Preferred width for this field.

getText

public String getText()
Description copied from class: TextField
Retrieves this field's text, not including the label.

Overrides:
getText in class TextField
Returns:
Text value contained in this field.

getText

public String getText(int offset,
                      int length)
Description copied from class: TextField
Retrieves a portion of this field's text.

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.

Overrides:
getText in class TextField
Parameters:
offset - First character to return.
length - Number of characters to return; must be at least 1.
Returns:
Substring of this field's contents.

getText

public void getText(int srcBegin,
                    int srcEnd,
                    char[] dst,
                    int dstBegin)
Description copied from class: TextField
Retrieves this field's text.

Note: This method adjusts for the label in the field's contents, so the srcBegin and srcEnd parameters describe the field's actual contents.

Overrides:
getText in class TextField
Parameters:
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.
Since:
BlackBerry API 4.0.0

getTextAbstractString

public AbstractString getTextAbstractString()
Description copied from class: TextField
Retrieves read-only handle to the underlying buffer.

Note: The underlying buffer can be modified by this field if methods such as TextField.insert(java.lang.String) or TextField.selectionDelete() are invoked.

Overrides:
getTextAbstractString in class TextField
Returns:
Underlying buffer for this field.

getTextLength

public int getTextLength()
Description copied from class: TextField
Retrieves length of this field's text, not including the label.

Overrides:
getTextLength in class TextField
Returns:
Number of characters in this field's text value.

insert

public int insert(String text)
Description copied from class: TextField
Inserts string programmatically into this field.

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).

Overrides:
insert in class TextField
Parameters:
text - String to insert.
Returns:
Number of characters successfully inserted.

insert

protected int insert(String text,
                     int context)
Description copied from class: TextField
Inserts string into this field.

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.

Overrides:
insert in class TextField
Parameters:
text - String to insert.
context - Information specifying the origin of the change. false indicates user-initiated insertion.
Returns:
Number of characters successfully inserted.

isSymbolScreenAllowed

protected boolean isSymbolScreenAllowed()
Description copied from class: TextField
Determines if this field supports use of the symbol screen.

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.

Overrides:
isSymbolScreenAllowed in class TextField
Returns:
true if this field supports the symbol screen; false if it does not.

layout

protected void layout(int width,
                      int height)
Description copied from class: TextField
Lays out this field's contents.

This field's manager invokes this method during the layout process to instruct this field to arrange its contents, given an amount of available space.

Overrides:
layout in class TextField
Parameters:
width - Horizontal space available.
height - Vertical space available.

paint

protected void paint(Graphics graphics)
Description copied from class: TextField
Redraws this field.

This field's manager invokes this method during the repainting process to instruct this field to repaint itself.

Overrides:
paint in class TextField
Parameters:
graphics - Graphics context for repainting this field.

setLabel

public void setLabel(String newLabel)
Description copied from class: TextField
Sets this field's label.

Overrides:
setLabel in class TextField
Parameters:
newLabel - New label for this field.

keyChar

protected boolean keyChar(char key,
                          int status,
                          int time)
Description copied from class: TextField
Traps key generation events.

This method, invoked by this field's manager, handles all key generation events, except for the special symbol screen event (triggered with ALT+SPACE) which is handled by Field.keyDown(int, int).

This method consumes all key events, except in the following cases:

Overrides:
keyChar in class TextField
Parameters:
key - Character generated by the event.
status - Modifier key status.
time - Number of milliseconds since the device was turned on.
Returns:
True if the event was consumed; otherwise, false.

keyControl

protected boolean keyControl(char key,
                             int status,
                             int time)
Description copied from class: TextField
Handles control character generation events.

This field's manager invokes this method to send this field a control character event.

Overrides:
keyControl in class TextField
Parameters:
key - Character generated.
status - Modifier key status. See KeypadListener.
time - Number of milliseconds since the device was turned on.
Returns:
True if this method consumed the event; otherwise, false.

keyDown

protected boolean keyDown(int keycode,
                          int time)
Description copied from class: Field
Handles key-down events.

By default, this method returns false. Custom fields that specially handle key down events must override this method.

Overrides:
keyDown in class Field
Parameters:
keycode - The code of the key that was pressed.
time - The number of milliseconds since the device was turned on.
Returns:
false. Classes that extend Field must override this method to provide specific handling.

update

protected void update(int delta)
Description copied from class: TextField
Updates this edit field.

This field invokes this method when text is inserted or deleted so this field can update itself.

Overrides:
update in class TextField
Parameters:
delta - Number of characters by which the field has changed, negative or positive (negative means that characters have been deleted).

setMaxSize

public void setMaxSize(int maxSize)
Description copied from class: TextField
Sets maximum number of characters allowed for this field's value.

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.

Overrides:
setMaxSize in class TextField
Parameters:
maxSize - New maximum number of characters for this edit field's value.

setCursorPosition

public void setCursorPosition(int offset)
Description copied from class: TextField
Places cursor on specific character within this field, at user request.

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.

Overrides:
setCursorPosition in class TextField
Parameters:
offset - Character position to receive the cursor, counting from the first character in this field's value.

setCursorPosition

protected void setCursorPosition(int offset,
                                 int context)
Description copied from class: TextField
Places cursor on specific character within this field.

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).

Overrides:
setCursorPosition in class TextField
Parameters:
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.

getCursorPosition

public int getCursorPosition()
Description copied from class: TextField
Retrieves character offset for current cursor position in this field.

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).

Overrides:
getCursorPosition in class TextField
Returns:
Character position of current cursor position within this field's value.

paste

public boolean paste(Clipboard cb)
Description copied from class: TextField
Pastes text scrap into this field.

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.

Overrides:
paste in class TextField
Parameters:
cb - Clipboard object holding the text scrap.
Returns:
True if this field is editable and paste operation was successful; otherwise, false.

moveFocus

protected int moveFocus(int amount,
                        int status,
                        int time)
Description copied from class: TextField
Handles moving focus within this field.

This field's manager invokes this method to prompt this field to handle a focus move event. If the event is an ALT-roll, then focus movement happens horizontally (character by character for trackwheel, begin/end of line for trackball); otherwise, focus movement happens vertically (line by line for trackwheel, page by page for trackball).

Prior to invoking this method, this field's manager invokes Field.focusRemove(). After invoking this method, the framework invokes Field.focusAdd(boolean). This method also clears this field's muddy state.

Overrides:
moveFocus in class TextField
Parameters:
amount - Number of positions to move, positive means down or forward, negative up or backwards.
status - Modifier key status.
time - Number of milliseconds since the device was turned on.
Returns:
Remaining scroll amount not used up, with the same sign.

moveFocus

protected void moveFocus(int x,
                         int y,
                         int status,
                         int time)
Description copied from class: TextField
Handles moving the focus to an exact position within this field.

This field's manager invokes this method when moving the focus to an exact position within this field, and only when this field already has the focus.

Overrides:
moveFocus in class TextField
Parameters:
x - Distance from left edge of this field for new focus position.
y - Distance from top edge of this field for new focus position.
status - Modifier key status.
time - Number of milliseconds since the device was turned on.
Since:
BlackBerry API 3.6.0

drawFocus

protected void drawFocus(Graphics graphics,
                         boolean on)
Description copied from class: TextField
Draws the focus indicator for this field.

This field's manager invokes this method after painting the field, in order to overpaint the focus indicator. By default, this method simply inverts the pixels in the focus's extent.

Note that if currently selecting more than one character in this field, then the focus region occupies the entire extent of the selected text.

Overrides:
drawFocus in class TextField
Parameters:
graphics - Graphics context for drawing the focus.
on - This parameter is ignored -- the focus is always set at the location at which it is drawn.
Since:
BlackBerry API 3.7.0

setFilter

public void setFilter(TextFilter filter)
Description copied from class: TextField
Sets the text filter for this field.

Overrides:
setFilter in class TextField
Parameters:
filter - Text filter for this field.

getFilter

public TextFilter getFilter()
Description copied from class: TextField
Gets the text filter set for this field.

Specified by:
getFilter in interface ITextInputStyle
Overrides:
getFilter in class TextField
Returns:
the text filter set for this field if exist otherwise return null;
Since:
BlackBerry API 4.0.0

setText

public void setText(String text)
             throws IllegalArgumentException
Description copied from class: TextField
Sets the text value for this field. The current text in the field is REPLACED by text.

Overrides:
setText in class TextField
Parameters:
text - New string value for this field; if null, this method clears the field.
Throws:
IllegalArgumentException - If the text cannot be entered into an edit field.

setText

protected void setText(String text,
                       int context)
                throws IllegalArgumentException
Description copied from class: TextField
Sets the text value for this field, with indication of the source of this action.

Overrides:
setText in class TextField
Parameters:
text - New string value for this field; if null, this method clears the field.
context - Information specifying the origin of the change.
Throws:
IllegalArgumentException - If the text cannot be entered into an edit field.

setFont

public void setFont(Font font)
Description copied from class: TextField
Sets the font for this field and updates the display if necessary.

Overrides:
setFont in class TextField
Parameters:
font - New font for this field.
Since:
BlackBerry API 3.7.0

getAccessibleContext

public AccessibleContext getAccessibleContext()
Accessibility.

Overrides:
getAccessibleContext in class TextField
Returns:
AccessibleContext
Since:
BlackBerry API 6.0.0





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