|
|||||||||
| 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.TextFieldBase
net.rim.device.api.input.InputHelperBase
public class InputHelperBase
Provides text input features and functionality of the input framework for Screen and Field classes
| Field Summary | ||
|---|---|---|
static long |
CONSUME_INPUT
Determines whether or not this field should consume all input characters; if it would normally. |
|
static long |
NO_NEWLINE
Ignore newlines from user input or pasting. |
|
| Constructor Summary | ||
|---|---|---|
InputHelperBase()
Constructs an InputHelperBase instance. |
||
InputHelperBase(long inputStyle)
Constructs an InputHelperBase instance. |
||
InputHelperBase(Screen scr)
Constructs an InputHelperBase instance. |
||
InputHelperBase(Screen scr,
long inputStyle)
Constructs an InputHelperBase instance with specified input style. |
||
| Method Summary | ||
|---|---|---|
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. |
|
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. |
|
void |
displayFieldFullMessage()
Displays a 'field full' message. |
|
void |
fieldChangeNotify(int context)
Invoked for this field when a change event occurs. |
|
AccessibleContext |
getAccessibleContext()
Returns accessible representation of the field for a screen reader |
|
int |
getAnchorPosition()
|
|
Screen |
getAssociatedScreen()
Gets a screen associated with this helper. |
|
int |
getCaretPosition()
|
|
static StringBuffer |
getCharVariants(int keycode)
Gets character variants (including umlauts) mapped to the keycode, depending on the device model, current input method, (virtual) keyboard layout, etc. |
|
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. |
|
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. |
|
ITextInputConnector |
getTextInputConnector()
Retrieves the currently registered requests listener. |
|
int |
getTextLength()
Retrieves length of this field's text, not including the label. |
|
int |
insert(String text)
Inserts string programmatically into this field. |
|
int |
insert(String text,
int context)
Inserts string into this field. |
|
boolean |
isFocusable()
States whether or not this helper accepts the focus. |
|
boolean |
isPasteable()
Determines if this field supports paste operations. |
|
boolean |
isScreenInput()
Checks if the helper is in screen input mode. |
|
boolean |
isSelectable()
Determines if this field supports selection of text. |
|
boolean |
isSelecting()
Determines if this field is currently selecting text. |
|
boolean |
isSelectionCopyable()
Determines if this field supports copy operations. |
|
boolean |
isSelectionDeleteable()
Determines if this field supports cut operations. |
|
protected boolean |
isSymbolScreenAllowed()
Determines if this field supports use of the symbol screen. |
|
boolean |
keyChar(char key,
int status,
int time)
Traps key generation events. |
|
boolean |
keyControl(char key,
int status,
int time)
Handles control character generation events. |
|
protected void |
makeContextMenu(ContextMenu contextMenu)
Builds this field's context menu. |
|
boolean |
paste(Clipboard cb)
Pastes text scrap into this field. |
|
void |
select(boolean enable)
Enables or disables selection mode. |
|
void |
selectionCopy(Clipboard cb)
Copies the current selection to the clipboard. |
|
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. |
|
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 |
setInputStyle(long style)
Sets text style for this helper's content. |
|
void |
setLabel(String newLabel)
Sets this field's label. |
|
void |
setLookupPosition(int x,
int y,
int widthOfText,
int heightOfText)
If ITextInputConnector listener is not registered with the helper then this method sets desirable (constant) position of the helper's lookup screen. |
|
void |
setMIDPDisplayable(Displayable displayable)
Associates the specified instance of MIDP Displayable with this helper, to dispatch input events to. |
|
void |
setMaxSize(int maxSize)
Sets maximum number of characters allowed for this field's value. |
|
boolean |
setScreenInput(boolean screenInputMode)
Sets this helper into 'screen input mode' or 'non-screen input mode'. |
|
void |
setSelection(int aNewCursor,
boolean aNewCursorLeadingEdge,
int aNewAnchor)
Set the selection. |
|
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. |
|
void |
setTextInputConnector(ITextInputConnector listener)
Registers an input framework request handler defined by a third party, with the InputHelperBase instance. |
|
protected void |
update(int delta)
Updates this edit field. |
|
protected void |
update(int aStart,
int aLength,
int aNewLength,
int aCursorOffset,
boolean aMoveCursor,
boolean aIsInsertionOrDeletion)
The update() method is called by the input framework when text or attributes change. |
|
void |
wipe()
Overwrites this field's unused contents. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface net.rim.device.api.im.ITextInputStyle |
|---|
getPreferredInputLocale, getTextInputStyle, isEditable, isUnicodeInputAllowed, updateInputStyle |
| Field Detail |
|---|
public static final long CONSUME_INPUT
Useful for fields that have Field.READONLY style set.
Modified value due to conflict with #JUMP_FOCUS_AT_END style.
public static final long NO_NEWLINE
Edit fields built with this style ignore newlines entered via cut and paste functionality and the keyboard. Labels can have newlines, but this field will strip newlines out of initial field values.
| Constructor Detail |
|---|
public InputHelperBase()
public InputHelperBase(long inputStyle)
inputStyle - Combination of field style bits to specify display and
filter attributes, e.g. BasicEditField.FILTER_NUMERIC, Field.EDITABLE, Field.FOCUSABLE.public InputHelperBase(Screen scr)
scr - Screen instance associated with this helper.
public InputHelperBase(Screen scr,
long inputStyle)
scr - Associated with this helper Screen instanceinputStyle - Combination of field style bits to specify display and
filter attributes, e.g. BasicEditField.FILTER_NUMERIC, Field.EDITABLE, Field.FOCUSABLE.| Method Detail |
|---|
public int getCaretPosition()
getCaretPosition in class TextFieldBaseInputMethodRequest#getCaretPositionpublic int getAnchorPosition()
getAnchorPosition in class TextFieldBaseInputMethodRequest#getAnchorPositionpublic int getLabelLength()
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 TextFieldBasepublic int backspace(int count)
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 TextFieldBasecount - Number of characters to delete.
public char charAt(int offset)
Index zero is the first character position after this field's label.
charAt in class TextFieldBaseoffset - Index of the character to retrieve.
IndexOutOfBoundsException - if offset is less than zero, or
greater than or equal to the value returned from InputHelperBase.getTextLength().public void clear(int context)
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 TextFieldBasecontext - Context ID for this action.public void wipe()
wipe in class TextFieldBasepublic void selectionDelete()
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 TextFieldBaseField.isSelectionDeleteable(),
Field.selectionCut(net.rim.device.api.system.Clipboard)public void selectionCopy(Clipboard cb)
Note that this method always succeeds, even if zero characters are copied onto the clipboard. If at least one character exists in the selection to copy, then this method overwrites the clipboard's previous contents. If there is no selection, then this method clears the contents of the clipboard.
selectionCopy in class TextFieldBasecb - Clipboard to contain copied text.
NullPointerException - if cb is null.public String getLabel()
getLabel in class TextFieldBasepublic int getMaxSize()
This method does not include this field's label as part of its accounting.
getMaxSize in class TextFieldBasepublic String getText()
getText in class TextFieldBase
public String getText(int offset,
int length)
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 TextFieldBaseoffset - First character to return.length - Number of characters to return.
public void getText(int srcBegin,
int srcEnd,
char[] dst,
int dstBegin)
This method adjusts for the label in the field's
contents, so the srcBegin and srcEnd parameters
describe the field's actual contents.
When srcEnd is a negative value, or srcBegin
is greater than srcEnd, this method leaves dst
as is and does not throw an exception.
getText in class TextFieldBasesrcBegin - First character in source to retrieve.srcEnd - Last character in source to retrieve.dst - Character buffer to contain retrieved text.dstBegin - Offset into buffer to receive the first retrieved
character.
ArrayIndexOutOfBoundsException - if one of the following is true:
srcBegin or dstBegin is negativesrcEnd is greater than the length of this field's
textdst is less than
(srcEnd - srcBegin + 1)dstBegin is greater than the last index of
dstNullPointerException - if dst is null.public AbstractString getTextAbstractString()
Note: The underlying buffer can be modified by this field if
methods such as InputHelperBase.insert(java.lang.String) or InputHelperBase.selectionDelete() are invoked.
getTextAbstractString in class TextFieldBasepublic int getTextLength()
getTextLength in class TextFieldBasepublic int insert(String text)
This method attempts to insert your specified 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 TextFieldBasetext - String to insert.
public int insert(String text,
int context)
This method attempts to insert your specified 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 TextFieldBasetext - String to insert.context - Information specifying the origin of the change. false
indicates user-initiated insertion.
public void setLabel(String newLabel)
setLabel in class TextFieldBasenewLabel - New label for this field.protected void update(int delta)
This field invokes this method when text is inserted or deleted so this field can update itself.
update in class TextFieldBasedelta - Number of characters by which the field has changed,
negative or positive (negative means that characters have been
deleted).public void setMaxSize(int maxSize)
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 TextFieldBasemaxSize - New maximum number of characters for this edit field's value.
IllegalArgumentException - If maxNumChars is less than zero.public void setCursorPosition(int offset)
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 TextFieldBaseoffset - Character position to receive the cursor, counting from the
first character in this field's value.public int getCursorPosition()
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 TextFieldBasepublic boolean paste(Clipboard cb)
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 TextFieldBasecb - Clipboard object holding the text scrap.
public void setFilter(TextFilter filter)
setFilter in class TextFieldBasefilter - Text filter for this field.public TextFilter getFilter()
getFilter in interface ITextInputStylegetFilter in class TextFieldBase
public void setText(String text)
throws IllegalArgumentException
text.
setText in class TextFieldBasetext - 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
setText in class TextFieldBasetext - 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.
public void setSelection(int aNewCursor,
boolean aNewCursorLeadingEdge,
int aNewAnchor)
setSelection in class TextFieldBaseaNewCursor - New cursor position.aNewCursorLeadingEdge - True if the cursor is at the leading edge of the character.aNewAnchor - New anchor position.
protected void update(int aStart,
int aLength,
int aNewLength,
int aCursorOffset,
boolean aMoveCursor,
boolean aIsInsertionOrDeletion)
Text starting at aStart, of length aLength, has just been replaced by text of aNewLength.
update in class TextFieldBaseaStart - A position in the text where the update starts.aLength - Length of the text chunk has been updated.aNewLength - Length of the new text chunk that replaced old text chunk.aCursorOffset - indicates cursor offset from aStart (may be non-zero in composed text).aMoveCursor - if true, cursor and anchor are moved accordinglyaIsInsertionOrDeletion - if true, insertion or deletion of text occurred, as the opposite to attribute changepublic final boolean isSelecting()
isSelecting in class TextFieldBaseField.select(boolean)public boolean isSelectable()
This method returns true as long as this field contains at least one character.
isSelectable in class TextFieldBasepublic void select(boolean enable)
Invoking this method to false sets the current selection to zero characters, and turns off the behaviour of increasing the selection with cursor movement.
select in class TextFieldBaseenable - True to enable selecting mode; false to disable it.public boolean isSelectionCopyable()
This method returns true if there is currently a selection (fields that can select text always have a selection, even if it's zero characters in size).
isSelectionCopyable in class TextFieldBasepublic boolean isSelectionDeleteable()
isSelectionDeleteable in class TextFieldBasepublic boolean isPasteable()
isPasteable in class TextFieldBaseField.EDITABLE; otherwise, false.protected boolean isSymbolScreenAllowed()
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 TextFieldBasetrue if this field supports the symbol screen;
false if it does not.public void displayFieldFullMessage()
displayFieldFullMessage in class TextFieldBase
public void setCursorPosition(int offset,
int context)
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 TextFieldBaseoffset - 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 boolean backspace()
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 TextFieldBase
public int backspace(int count,
int context)
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 TextFieldBasecount - Number of characters to delete.context - Information specifying the origin of the change.
public void fieldChangeNotify(int context)
Custom fields should call this function when their state changes.
The dirty state is cleared if the change was programmatic, and is set (dirtied) if the change was user driven.
fieldChangeNotify in class TextFieldBasecontext - Information specifying the origin of the change.protected void makeContextMenu(ContextMenu contextMenu)
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).
makeContextMenu in class TextFieldBasecontextMenu - The context menu to build.ContextMenupublic void setFont(Font font)
setFont in class TextFieldBasefont - New font for this field.public AccessibleContext getAccessibleContext()
TextFieldBase
getAccessibleContext in class TextFieldBaseField.getAccessibleContext()public void setMIDPDisplayable(Displayable displayable)
displayable - The MIDP Displayable instance to be associated with this helper.public void setInputStyle(long style)
style - Combination of field style bits to specify display and
filter attributes, e.g. BasicEditField.FILTER_NUMERIC, Field.EDITABLE, Field.FOCUSABLE.
public boolean keyChar(char key,
int status,
int time)
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:
InputHelperBase.NO_NEWLINE), and the ENTER key was pressed. EDITABLE (exception: if in
select mode, and the ENTER key was pressed).
keyChar in class TextFieldBasekey - Character generated by the event.status - Modifier key status.time - Number of milliseconds since the device was turned on.
public boolean keyControl(char key,
int status,
int time)
This field's manager invokes this method to send this field a control character event.
keyControl in class TextFieldBasekey - Character generated.status - Modifier key status. See KeypadListener.time - Number of milliseconds since the device was turned on.
public boolean isFocusable()
isFocusable in class Fieldpublic Screen getAssociatedScreen()
getAssociatedScreen in class TextFieldBaseScreen.public boolean isScreenInput()
Being in screen input mode means that input events are dispatched to this helper that uses TID service to process the input events.
Not being in screen input mode means that input events are dispatched to a component if any has been added to a container (e.g. Screen) associated with this helper and has been given the focus.
If no component was added to the container then the helper cannot be switched to non-screen input mode.
In order to switch between screen input mode and non-screen input mode,
an application have to call setScreenInput() method directly.
Adding a component to the container does not guarantee automatic switch of the helper to non-screen input mode.
public boolean setScreenInput(boolean screenInputMode)
screenInputMode - True to set screen input mode; false to set non-screen input mode.
IllegalStateException - if there is no screen associated with this helper.public static StringBuffer getCharVariants(int keycode)
keycode - A keycode.
public ITextInputConnector getTextInputConnector()
public void setTextInputConnector(ITextInputConnector listener)
InputHelperBase instance.
The handler is to provide the input framework with information about the typed text, e.g. the text location,
so that the input framework will know where to display lookup popup, etc.
requestsListener - Input framework request handler.
IllegalStateException - if there is already a listener registered and listener is not null.
public void setLookupPosition(int x,
int y,
int widthOfText,
int heightOfText)
Specifies a rectangle (x,y,w,h) where text is placed in the application screen. The lookup is to be positioned nearby.
x - X position of a text.y - Y position of a text.widthOfText - width of text.heightOfText - height of text.IInputLocationRequests.getTextLocation(net.rim.device.api.im.TextHitInfo, net.rim.device.api.ui.XYRect)
|
|||||||||
| 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