com.nokia.mid.ui
Class TextEditor

java.lang.Object
  extended by com.nokia.mid.ui.CanvasItem
      extended by com.nokia.mid.ui.TextEditor

public class TextEditor
extends CanvasItem

A TextEditor is an editable text component that is used with a parent object; with Canvas or CustomItem. The TextEditor maybe set to and removed from Canvas through setParent() method.

TextEditor supports input constraints identically to TextField. See input constraints section in the TextField for the definition of these constants. In addition TextEditor has the same concept of actual contents and displayed contents as TextField; these are described in the same input constraints section.

TextEditor supports input modes identically to TextField. See input modes section in the TextField for the definition of these constants.

The text may contain line breaks. The display of the text must break accordingly and the user must be able to enter line break characters.

The TextEditor provides necessary interaction for example for touch input (handwriting recognition) on touch screen devices and selection of additional characters. The input on touch devices requires additional windows of top of the editor window which depending on the implementation may obscure the parent completely.

Application can add a TextEditorListener to the TextEditor for example for keeping track of user navigation (caret movement) and other content changes such as text selection. The events are sent on all occasions that cause the caret position to change (including but not limited to text typing by user, programmatic text insertion, navigation within the TextEditor content, and text deletion). The events must be sent to the application prior to they have effect on the editor - for example an event indicating caret movement must be available for the application before the implementation actually moves the caret in the editor.

When the TextEditor has focus all the key events that are not consumed by TextEditor with the current constraints or mapped to Commands by the implementation are sent to Canvas.

Touch pointer events are not delivered to parent object from the area of the visible TextEditor.

The implementation will scroll the TextEditor content automatically on user interaction and when the application calls setCaret or setSelection methods. For example if a user clicks down on the last visible row the TextEditor content is scrolled accordingly by one row. However the Java platform implementation does not draw any scroll bars, this is left to the application.

Since:
1.4

Field Summary
static int DISABLE_SMILEY_MODE
          This flag is a hint to the implementation that during text editing, the smiley key should be disabled on the virtual keyboard.
 
Fields inherited from class com.nokia.mid.ui.CanvasItem
SCALE_AVERAGE, SCALE_NEAREST, SCALE_NOT_ALLOWED
 
Method Summary
static TextEditor createTextEditor(int maxSize, int constraints, int width, int rows)
           Creates a new empty TextEditor with the given maximum size in characters, constraints and editor size as number of visible rows.
static TextEditor createTextEditor(java.lang.String text, int maxSize, int constraints, int width, int height)
           Creates a new TextEditor object with the given initial contents, maximum size in characters, constraints and editor size in pixels.
 void delete(int offset, int length)
           Deletes characters from the TextEditor.
 int getBackgroundColor()
          Gets the background color and alpha of this TextEditor.
 int getCaretPosition()
          Gets the current position of the caret in the editor.
 int getConstraints()
          Gets the current input constraints of this TextEditor.
 java.lang.String getContent()
          Gets the string content in the TextEditor.
 int getContentHeight()
          Gets the whole content height in this TextEditor in pixels.
 int getDisabledTouchInputModes()
          By default all supported touch input modes are available.
 javax.microedition.lcdui.Font getFont()
           Gets the font being used in rendering the text content in this TextEditor.
 int getForegroundColor()
          Gets the foreground color and alpha of this TextEditor
 int[] getIndicatorSize()
          Gets the size of the area needed for drawing the input indicators.
 java.lang.String getInitialInputMode()
          Returns the initial input mode set to the editor, or null if no initial input mode has been set.
 int getLineMarginHeight()
          Gets the line margin height in this TextEditor in pixels.
 int getMaxSize()
          Returns the maximum size (number of characters) that can be stored in this TextEditor.
 int getPreferredTouchMode()
          Gets the preferred touch input mode.
 java.lang.String getSelection()
          Gets the currently selected content in the TextEditor.
 int getVisibleContentPosition()
           Gets the topmost pixel position of the topmost visible line in the editor.
 int getZPosition()
           Returns the Z-position, or the elevation, of the item.
 boolean hasFocus()
          Returns the focus state of TextEditor.
 void insert(java.lang.String text, int position)
           Inserts a string into the content of the TextEditor.
 boolean isMultiline()
          Returns the multiline state of the TextEditor.
 boolean isTouchEnabled()
          Gets the current touch-enabled state
 void setBackgroundColor(int color)
          Sets the background color and alpha of this TextEditor to the specified values.
 void setCaret(int index)
           Sets the index of the caret.
 void setCaretXY(int x, int y)
          Sets the caret in the Editor at x, y location.
 void setConstraints(int constraints)
          Sets the input constraints of this TextEditor.
 void setContent(java.lang.String content)
          Sets the content of the TextEditor as a string.
 void setDefaultIndicators()
           Resets the implementation provided input indicators to their default position.
 void setDisabledTouchInputModes(int touchInputModes)
          Disables one or multiple touch input modes from use.
 void setFocus(boolean focused)
          Sets this TextEditor focused or removes keyboard focus.
 void setFont(javax.microedition.lcdui.Font font)
           Sets the application preferred font for rendering the text content in this TextEditor.
 void setForegroundColor(int color)
          Sets the foreground color and alpha of this TextEditor to the specified values.
 void setHighlightBackgroundColor(int color)
          Sets the highlight background color.
 void setHighlightForegroundColor(int color)
          Sets the highlight foreground color.
 void setIndicatorLocation(int x, int y)
           If the default indicator location is not used then sets the drawing location for input indicators relative to the TextEditor's parent.
 void setIndicatorVisibility(boolean visible)
           By default indicators visibility is set to true and they are made visible when the associated TextEditor is focused.
 void setInitialInputMode(java.lang.String characterSubset)
           Sets a hint to the implementation as to the input mode that should be used when the user initiates editing of this TextEditor.
 int setMaxSize(int maxSize)
          Sets the maximum size (number of characters) that can be contained in this TextEditor.
 void setMultiline(boolean aMultiline)
          Sets the editor to be either multi-line (true) or single-line (false).
 void setParent(java.lang.Object theParent)
          Set the parent object of this TextEditor.
 void setPosition(int x, int y)
           Sets the rendering position of this TextEditor.
 void setPreferredTouchMode(int touchInputModes)
          Set the preferred touch input mode overriding the device default preferred mode.
 void setSelection(int index, int length)
           Sets a selection on a range of text in the TextEditor content.
 void setSize(int width, int height)
          Sets the size of this TextEditor in pixels.
 void setTextEditorListener(TextEditorListener listener)
           Sets a listener for content changes in this TextEditor, replacing any previous TextEditorListener.
 void setTouchEnabled(boolean enabled)
          Specifies whether or not the editor will receive touch-events.
 void setVisible(boolean visible)
           Sets the visibility value of TextEditor.
 void setZPosition(int z)
           Sets the Z-position, or the elevation, of the item.
 int size()
          Gets the number of characters that are currently stored in this TextEditor.
 
Methods inherited from class com.nokia.mid.ui.CanvasItem
getHeight, getParent, getPositionX, getPositionY, getWidth, isValidImageAnchor, isVisible, scale, scale, setScalingMode, setSize
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISABLE_SMILEY_MODE

public static final int DISABLE_SMILEY_MODE
This flag is a hint to the implementation that during text editing, the smiley key should be disabled on the virtual keyboard. This hint may alternatively remove the smiley key alltogether.

Constant 0x400000 is assigned to DISABLE_SMILEY_MODE.

See Also:
Constant Field Values
Method Detail

createTextEditor

public static TextEditor createTextEditor(java.lang.String text,
                                          int maxSize,
                                          int constraints,
                                          int width,
                                          int height)

Creates a new TextEditor object with the given initial contents, maximum size in characters, constraints and editor size in pixels.

If the text parameter is null, the TextEditor is created empty.

The maxSize parameter must be greater than zero. An IllegalArgumentException is thrown if the length of the initial contents string exceeds maxSize. However, the implementation may assign a maximum size smaller than the application had requested. If this occurs, and if the length of the contents exceeds the newly assigned maximum size, the contents are truncated from the end in order to fit, and no exception is thrown.

Parameters:
text - the initial contents, or null if the TextEditor is to be created empty
maxSize - the maximum capacity in characters
constraints - see the input constraints in TextField
width - the width of the bounding box, in pixels
height - the height of the bounding box, in pixels
Returns:
Instance of TextEditor
Throws:
java.lang.IllegalArgumentException - if aMaxSize is zero or less
java.lang.IllegalArgumentException - if the value of the constraints parameter is invalid
java.lang.IllegalArgumentException - if aText is illegal for the specified constraints
java.lang.IllegalArgumentException - if the length of the string exceeds the requested maximum capacity
java.lang.IllegalArgumentException - if the width or height is less than one pixel

createTextEditor

public static TextEditor createTextEditor(int maxSize,
                                          int constraints,
                                          int width,
                                          int rows)

Creates a new empty TextEditor with the given maximum size in characters, constraints and editor size as number of visible rows.

The rows parameter indicates the requested number of visible rows in the editor. TextEditor then assigns the initial height for the editor based on the requested number of rows and width of the editor.

The maxSize parameter must be greater than zero. An IllegalArgumentException is thrown if the length of the initial contents string exceeds maxSize. However, the implementation may assign a maximum size smaller than the application had requested. If this occurs, and if the length of the contents exceeds the newly assigned maximum size, the contents are truncated from the end in order to fit, and no exception is thrown.

Parameters:
maxSize - the maximum capacity in characters
constraints - see the input constraints in TextField
width - the width of the bounding box, in pixels
rows - the requested number of visible rows in the editor
Returns:
Instance of TextEditor
Throws:
java.lang.IllegalArgumentException - if aMaxSize or aRows is zero or less
java.lang.IllegalArgumentException - if the value of the constraints parameter is invalid
java.lang.IllegalArgumentException - if the length of the string exceeds the requested maximum capacity
java.lang.IllegalArgumentException - if the width is less than one pixel

setFocus

public void setFocus(boolean focused)
Sets this TextEditor focused or removes keyboard focus. Calling setFocus(true) enables text editing from keys as the delivery of needed key events will be targeted to the TextEditor instead of the parent object (e.g. Canvas). Focus needs to be explicitly set to the TextEditor by application. When Canvas or CustomItem does not have any focused TextEditor all key and pointer events are delivered to normal key delivery methods of parent. Necessary key events are captured by TextEditor only when it has focus.

The setFocus affects to the parent key event delivery in following way: If all TextEditors are unfocused the key event delivery of parent works as if there are not any TextEditors in it, only when a focus is set via this method to a TextEditor the key event delivery is modified. The focused editor starts to capture the necessary key events and these key events are not delivered to parent. The set of key events captured depends on TextEditor implementation and device HW but in most implementations nearly all device keys are captured by the editor for text insertion, input mode changes and caret move functionalities. Especially applications should not assume to get key events from keys mapped to game actions as most probably the same keys are used to navigate the text caret within the editor. The keys that are used for Command launching in Canvas are available for applications on focused TextEditor and these keys either launch commands or send low-level key events as normally.

Setting focus does not cause any visual focus indication by the implementation other than showing the caret. Any other change in the visual appearance of the editor in focused state is the responsibility of the application; this can be done for example by drawing a focus border around the TextEditor or by changing the background color or transparency of the editor.

If this TextEditor has already been focused earlier and the editor contents has not changed after previous unfocusing, then after calling setFocus again the caret position should be retained.

If there already is another focused TextEditor on the Canvas, the focus is first removed from that TextEditor before setting this TextEditor focused.

Calling setFocus(false) disables key based text editing and returns the delivery of key events and pointer events to the underlying Canvas.

Parameters:
focused - keyboard focus of the TextEditor
Throws:
java.lang.IllegalStateException - If the TextEditor is not added to Canvas
See Also:
hasFocus()

hasFocus

public boolean hasFocus()
Returns the focus state of TextEditor.

Returns:
the focus state of the editor
See Also:
setFocus(boolean focused)

setParent

public void setParent(java.lang.Object theParent)
Set the parent object of this TextEditor.

Typically the parent object would be Canvas. Setting the parameter to null removes the association to the parent. If setParent(null) is called for a TextEditor yet not having any parent or setParent(parent) is called with the same parent, the call is silently ignored.

Overrides:
setParent in class CanvasItem
Parameters:
parent - the parent object
Throws:
java.lang.IllegalArgumentException - if parent is not a valid object with which a TextEditor can be associated, or if CanvasItem is already set to another another parent

setSize

public void setSize(int width,
                    int height)
Sets the size of this TextEditor in pixels.

Overrides:
setSize in class CanvasItem
Parameters:
width - width in pixels
height - height in pixels
Throws:
java.lang.IllegalArgumentException - if the width or height is less than one pixel
See Also:
for more details

setPosition

public void setPosition(int x,
                        int y)

Sets the rendering position of this TextEditor. The anchor point given is relative to the upper left corner of the parent, Canvas.

The TextEditor may be placed fully off or partially of the visible area of the parent, Canvas, by the setPosition method; in this case the TextEditor is just partly visible.

Overrides:
setPosition in class CanvasItem
Parameters:
x - the x coordinate of the anchor point, in pixels.
y - the y coordinate of the anchor point, in pixels.
Throws:
java.lang.IllegalStateException - if a valid parent object has not been set.
See Also:
setParent(java.lang.Object parent)

setVisible

public void setVisible(boolean visible)

Sets the visibility value of TextEditor. Initially TextEditor is not visible so it must be explicitly set to visible in order it to appear on UI.

Setting visibility to true shows the editor with its content, but without the caret. If the editor does not have any visible content and does not have any background color set then this method effectively does not cause any visual change in the display. If the editor is already visible calling setVisible(true) does nothing.

Setting the visibility to false hides the editor and its content. If the TextEditor has focus then the focus is removed. If the editor is already hidden calling setVisible(false) does nothing.

Overrides:
setVisible in class CanvasItem
Parameters:
visible - visibility of the TextEditor
Throws:
java.lang.IllegalStateException - if a valid parent object has not been set.
See Also:
setParent(java.lang.Object parent)

setZPosition

public void setZPosition(int z)

Sets the Z-position, or the elevation, of the item.

The elevation decides the stacking order of neighboring items. An item of high Z-position will be drawn on top of an item with a lower Z-position if they share the same parent item.

The z-position is unique for each item meaning that changing a Z-position of an item may change the Z-position of the items that share the same parent item. The Z-position does not affect the item's size in any way.

When items are added with CanvasItem.setParent(java.lang.Object) they will get a Z-position that is increased by 1 from the item that is the top most item at that time.

Overrides:
setZPosition in class CanvasItem
Parameters:
z - the Z-position of the item.
Throws:
java.lang.IllegalArgumentException - If z < 0
java.lang.IllegalStateException - if a valid parent object has not been set.
See Also:
getZPosition(), setParent(java.lang.Object parent)

setTouchEnabled

public void setTouchEnabled(boolean enabled)
Specifies whether or not the editor will receive touch-events.

This is enabled by default. An editor with touch-event disabled won't be able to perform any touch-related functionality such as scrolling or positioning the cursor. It may however still be controlled via the virtual keypad/control-panel if that is enabled, or receive other + input e.g. via physical keys

Parameters:
enabled - true to enabled touch-event, false to disable

isTouchEnabled

public boolean isTouchEnabled()
Gets the current touch-enabled state

Returns:
true if the editor is touch-enabled, false otherwise

getZPosition

public int getZPosition()

Returns the Z-position, or the elevation, of the item. The Z-position decides the stacking order of neighboring items.

Overrides:
getZPosition in class CanvasItem
Returns:
the Z-position of the item.
Throws:
java.lang.IllegalStateException - if a valid parent object has not been set.
See Also:
setZPosition(int), setParent(java.lang.Object parent)

getLineMarginHeight

public int getLineMarginHeight()
Gets the line margin height in this TextEditor in pixels.

Gets the possible line margin height that editor has in addition to the normal font height (Font getHeight()). The returned value is 0 if the editor does not have any additional line margins to the text height returned from getHeight() of Font set to the editor.

Returns:
the line margin height in pixels
See Also:
setParent(java.lang.Object parent)

getContentHeight

public int getContentHeight()
Gets the whole content height in this TextEditor in pixels.

The returned value must include the height of the whole content in the editor, not just the height of the visible content.

Note that the method returns 0, if the editor has no parent.

Returns:
the height of the whole content in the editor in pixels
See Also:
setParent(java.lang.Object parent)

setCaret

public void setCaret(int index)

Sets the index of the caret. The caret can be used to indicate a position in the text.

The Java platform implementation must scroll the content of the TextEditor automatically so that the caret is within the visible area. If the caret is set above the visible area the content should be scrolled so that the caret is on the top most visible row. If the caret is set below the visible area the content should be scrolled so that the caret is on the lowest visible row.

Parameters:
index - the character index before which to place the caret
Throws:
java.lang.StringIndexOutOfBoundsException - if index does not specify a valid range within the content of the TextEditor

getCaretPosition

public int getCaretPosition()
Gets the current position of the caret in the editor.

Returns:
the current caret position, 0 if at the beginning

getVisibleContentPosition

public int getVisibleContentPosition()

Gets the topmost pixel position of the topmost visible line in the editor.

The returned y coordinate value is relative to the whole content height, not just the visible part.

This method can be used by the application together with the getContentHeight, height of the font, getLineMarginHeight, and getCaretPosition methods in drawing custom visual cues like a scroll bar or other content sensitive pop-ups.

Note that the method returns 0, if the editor has no parent.

Returns:
the topmost pixel position of the visible content.

getFont

public javax.microedition.lcdui.Font getFont()

Gets the font being used in rendering the text content in this TextEditor.

Returns:
the font being used in this TextEditor

setFont

public void setFont(javax.microedition.lcdui.Font font)

Sets the application preferred font for rendering the text content in this TextEditor. Setting the font is a hint to the implementation, and the implementation may disregard the requested font.

The font parameter must be a valid Font object or null. If the font parameter is null, the implementation must use its default font to render the text content.

Parameters:
font - the application preferred font to be used in this TextEditor

getBackgroundColor

public int getBackgroundColor()
Gets the background color and alpha of this TextEditor.

Returns:
the background color

getForegroundColor

public int getForegroundColor()
Gets the foreground color and alpha of this TextEditor

Returns:
the foreground color

setBackgroundColor

public void setBackgroundColor(int color)
Sets the background color and alpha of this TextEditor to the specified values. The default background color for editor is fully transparent white.

Parameters:
color - the color

setForegroundColor

public void setForegroundColor(int color)
Sets the foreground color and alpha of this TextEditor to the specified values. The content, e.g. text, in the editor must be drawn with this color. The default foreground color is fully opaque black.

Parameters:
color - the color

setHighlightBackgroundColor

public void setHighlightBackgroundColor(int color)
Sets the highlight background color. This impacts text background color for the selected text. The text in a current selection range will be rendered using given color value. The default highlight background color is fully opaque black. This method is not supported on S40 platform.

Parameters:
color - the color

setHighlightForegroundColor

public void setHighlightForegroundColor(int color)
Sets the highlight foreground color. This impacts text color for the selected text. The text in a current selection range will be rendered using given color value. The default highlight foreground color is fully opaque white. This method is not supported on S40 platform.

Parameters:
color - the color

setContent

public void setContent(java.lang.String content)
Sets the content of the TextEditor as a string. The set string replaces any previous content in the editor.

Parameters:
content - the new content of the TextEditor as string, null empties the TextEditor
Throws:
java.lang.IllegalArgumentException - if aContent is illegal for the current input constraints
java.lang.IllegalArgumentException - if the given text would exceed the current maximum capacity of the editor

getContent

public java.lang.String getContent()
Gets the string content in the TextEditor.

Returns:
The editor current content

insert

public void insert(java.lang.String text,
                   int position)

Inserts a string into the content of the TextEditor.

The string is inserted just prior to the character indicated by the position parameter, where zero specifies the first character of the content in the TextEditor. If position is less than or equal to zero, the insertion occurs at the beginning of the content. If position is greater than or equal to the current size of the content, the insertion occurs immediately after the end of the content.

The current size of the contents is increased by the number of inserted characters. The resulting string must fit within the current maximum capacity.

Parameters:
text - the String to be inserted
position - the position at which insertion is to occur
Throws:
java.lang.IllegalArgumentException - if the resulting content would be illegal for the current input constraints
java.lang.IllegalArgumentException - if the insertion would exceed the current maximum capacity
java.lang.NullPointerException - if text is null

delete

public void delete(int offset,
                   int length)

Deletes characters from the TextEditor.

The offset and length parameters must specify a valid range of characters within the contents of the TextEditor. The offset parameter must be within the range [0..(size())], inclusive. The length parameter must be a non-negative integer such that (offset + length) <= size().

Parameters:
offset - the beginning of the region to be deleted
length - the number of characters to be deleted
Throws:
java.lang.IllegalArgumentException - if the resulting contents would be illegal for the current input constraints
java.lang.StringIndexOutOfBoundsException - if offset and length do not specify a valid range within the content of the TextEditor

getMaxSize

public int getMaxSize()
Returns the maximum size (number of characters) that can be stored in this TextEditor.

Returns:
the maximum size in characters

setMaxSize

public int setMaxSize(int maxSize)
Sets the maximum size (number of characters) that can be contained in this TextEditor. If the current content of the TextEditor is larger than the new maxSize, the content is truncated to fit.

Parameters:
maxSize - the new maximum size
Returns:
assigned maximum capacity - may be smaller than requested.
Throws:
java.lang.IllegalArgumentException - if maxSize is zero or less.
java.lang.IllegalArgumentException - if the contents after truncation would be illegal for the current input constraints

size

public int size()
Gets the number of characters that are currently stored in this TextEditor.

Returns:
the number of characters

setConstraints

public void setConstraints(int constraints)
Sets the input constraints of this TextEditor. If the current content of this TextEditor do not match the new constraints, the content is set to empty.

Parameters:
constraints - see input constraints
Throws:
java.lang.IllegalArgumentException - if the value of the constraints parameter is invalid

getConstraints

public int getConstraints()
Gets the current input constraints of this TextEditor.

Returns:
the current constraints value (see input constraints)

setInitialInputMode

public void setInitialInputMode(java.lang.String characterSubset)

Sets a hint to the implementation as to the input mode that should be used when the user initiates editing of this TextEditor. The characterSubset parameter names a subset of Unicode characters that is used by the implementation to choose an initial input mode. If null is passed, the implementation should choose a default input mode.

See Input Modes for a full explanation of input modes.

Parameters:
characterSubset - a string naming a Unicode character subset, or null

getInitialInputMode

public java.lang.String getInitialInputMode()
Returns the initial input mode set to the editor, or null if no initial input mode has been set.

Returns:
the initial input mode as a String, or null if no initial input mode is set.
See Also:
setInitialInputMode(String characterSubset )

setSelection

public void setSelection(int index,
                         int length)

Sets a selection on a range of text in the TextEditor content. The implementation should highlight the selection visually. A selection may be set with this method or by user interaction. If there already is a selection set, it is replaced by this new selection.

The caret must be automatically set directly after the set selection. The Java platform implementation must scroll the content of the TextEditor automatically so that the caret is within the visible area and as much as possible of the selection is visible in the TextEditor.

Parameters:
index - the index of the first character to be selected.
length - the length of the selection in characters, 0 length clears the selection.
Throws:
java.lang.StringIndexOutOfBoundsException - if index and length do not specify a valid range within the content of the TextEditor

getSelection

public java.lang.String getSelection()
Gets the currently selected content in the TextEditor. A selection may be set with setSelection method or by user interaction. If selection is not set non-null empty string is returned.

Returns:
the currently selected content

setTextEditorListener

public void setTextEditorListener(TextEditorListener listener)

Sets a listener for content changes in this TextEditor, replacing any previous TextEditorListener.

A null reference is allowed and has the effect of removing any existing TextEditorListener from this TextEditor.

Callbacks to the TextEditorListener may throw exceptions, but they must be ignored.

Parameters:
listener - the new listener, or null

isMultiline

public boolean isMultiline()
Returns the multiline state of the TextEditor.

Returns:
the multiline state

setMultiline

public void setMultiline(boolean aMultiline)
Sets the editor to be either multi-line (true) or single-line (false). TextEditor is by default single-line editor, which meeans that user is not possible to insert line breaks to the editor. A possible Enter (or similar) key event should be passed in this case to the parent object as a normal key event for client to handle it as appropriately. A single-line editor will have horizontal scrolling of text if it is possible to enter text that does not fit to the editor. This may happen if maximum size is large enough for the width of the editor. In multi-line editor user is able to insert line breaks but also word wrapping is enabled automatically on word boundaries.

Parameters:
aMultiline - true if multi-line editor, false if single-line editor
Throws:
java.lang.IllegalStateException - if a valid parent object has not been set.

setIndicatorLocation

public void setIndicatorLocation(int x,
                                 int y)

If the default indicator location is not used then sets the drawing location for input indicators relative to the TextEditor's parent.

The anchor point given is relative to the upper left corner of the Canvas. The location may be outside the TextEditor boundaries. The z-order of the indicators is the same as TextEditor textual content. If indicators and the editor content overlap indicators are rendered on top of the editor content.

The application should first query the size of the input indicators with getIndicatorSize() method to determine that the indicators will not be clipped outside the available display area when drawn to the requested location.

If there are no indicators present, the usability of complex device specific input methods may be compromised.

Parameters:
x - the x coordinate of the anchor point, in pixels.
y - the y coordinate of the anchor point, in pixels.

setDefaultIndicators

public void setDefaultIndicators()

Resets the implementation provided input indicators to their default position.

This position may be outside the area of parent in case the default position is in status area. In this case if the status area is missing (full screen mode Canvas) the default position is inside the parent area e.g. on top of the editor. When default position is in use the TextEditor automatically positions the indicators relative to the TextEditor even when TextEditor location is changed. However, client is responsible of making sure indicators are visible inside the parent area positioning TextEditor so that indicators fit to the visible area e.g. on top of the TextEditor. Positioning TextEditor directly on top of Canvas may mean that indicators in the default position are not visible.

Throws:
java.lang.IllegalStateException - If the TextEditor is not added to Canvas

setIndicatorVisibility

public void setIndicatorVisibility(boolean visible)

By default indicators visibility is set to true and they are made visible when the associated TextEditor is focused.

If the application controls the position of the indicators, those can be explicitly made not visible by calling setIndicatorVisibility(false). Indicators are never visible if TextEditor itself is not visible so having indicator visibility set to true does not make them visible unless editor itself is set visible.

Parameters:
visible - controls indicator visibility state
See Also:
setIndicatorLocation(int, int), setDefaultIndicators()

getIndicatorSize

public int[] getIndicatorSize()
Gets the size of the area needed for drawing the input indicators.

The returned array contains two integers for width (array index 0) and height (array index 1) of the indicator graphics. Size (0,0) is returned if the device UI does not use any input indicators in the text editors or if the indicators are curretly positioned outside parent area e.g. in status area. This happens if setIndicatorLocation(int x, int y) has not been ever called for the editor, or if setDefaultIndicators() has been called.

Returns:
the width and height of area needed for drawing input indicators
See Also:
setDefaultIndicators()

setDisabledTouchInputModes

public void setDisabledTouchInputModes(int touchInputModes)
Disables one or multiple touch input modes from use.

User is not able to switch to the disable touch input modes. Multiple touch input modes may be combined together in touchInputMode parameter using bitwise or operator. The method does not have any impact if called in non-touch device. A device may not support all touch input modes specified. Specifying not supported input modes is silently ignored.

The possible values are defined in the class with TOUCH_INPUT_* starting constant values.

Parameters:
touchInputModes - bitwise or combined list of disabled touch input modes
Throws:
java.lang.IllegalArgumentException - if the given input modes are not valid.

See Also:
setPreferredTouchMode(int), getDisabledTouchInputModes()

getDisabledTouchInputModes

public int getDisabledTouchInputModes()
By default all supported touch input modes are available. Returns the disabled touch input modes set with setDisabledTouchInputModes(int).

Note that the disabled touch input modes may be device specific so this method may return some modes as disabled by default.

Note that if the device does not support touch input this method returns all modes.

Returns:
The disabled touch input modes.
See Also:
setDisabledTouchInputModes(int), setPreferredTouchMode(int)

setPreferredTouchMode

public void setPreferredTouchMode(int touchInputModes)
Set the preferred touch input mode overriding the device default preferred mode. User may still change the touch input mode from touch input window to all available modes.

The possible values are defined in the class with TOUCH_INPUT_* starting constant values.

Note that if the device does not support touch input this method has no effect.

Parameters:
touchInputModes - a touch input mode to be set as preferred one.
Throws:
java.lang.IllegalArgumentException - if the input mode is not valid or if it contains multiple input modes as bit mask.
See Also:
setDisabledTouchInputModes(int), getPreferredTouchMode()

getPreferredTouchMode

public int getPreferredTouchMode()
Gets the preferred touch input mode.

Note that if the device does not support touch input this method returns 0

Returns:
The preferred touch input mode.

See Also:
setPreferredTouchMode(int), setDisabledTouchInputModes(int)

setCaretXY

public void setCaretXY(int x,
                       int y)
Sets the caret in the Editor at x, y location.

Parameters:
x - The x coordinate of the wanted caret position.
y - The y coordinate of the wanted caret position.


Copyright © 2012 Nokia Corporation. All rights reserved.

Nokia is registered trademark of Nokia Corporation. Java and all Java-based marks are trademarks or registered trademarks of Oracle Corporation. Other product and company names mentioned herein may be trademarks or trade names of their respective owners. This document is confidential information of Nokia Corporation.

Disclaimer
The information in this document is provided "as is," with no warranties whatsoever, including any warranty of merchantability, fitness for any particular purpose, or any warranty otherwise arising out of any proposal, specification, or sample. Furthermore, information provided in this document is preliminary, and may be changed substantially prior to final release.

Nokia Corporation disclaims all liability, including liability for infringement of any proprietary rights, relating to this document and implementation of any information presented in this document.

Nokia Corporation retains the right to make changes to this document at any time, without notice.

License
Subject to above disclaimer, a license is hereby granted to use this documentation solely under existing Limited License Agreement and non-disclosure agreement between the companies for the agreed application development for Series 40 Nokia phones. No other licenses e.g. to any intellectual property rights are granted herein. Any use of the screen shots of this documentation, including any icons thereof, is subject to Nokia's prior written approval.