|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.microedition.lcdui.Item
javax.microedition.lcdui.CustomItem
de.enough.polish.ui.FakeCustomItem
de.enough.polish.ui.FakeStringCustomItem
de.enough.polish.ui.FakeTextFieldCustomItem
de.enough.polish.ui.ChoiceTextField
public class ChoiceTextField
Provides a TextField that provides the user with possible matches for the current input.
Copyright Enough Software 2006 - 2008
history
27-Feb-2006 - rob creation
| Field Summary | |
|---|---|
static int |
MATCH_INDEX_OF
The matching mode that selects choices that contain the same characters as the current input |
static int |
MATCH_STARTS_WITH
The matching mode that selects choices that start with the same characters as the current input |
| Fields inherited from class de.enough.polish.ui.FakeTextFieldCustomItem |
|---|
ANY, caretChar, CLEAR_CMD, CONSTRAINT_MASK, DECIMAL, DELETE_CMD, EMAILADDR, emailSeparatorChar, flashCaret, INITIAL_CAPS_SENTENCE, INITIAL_CAPS_WORD, isUneditable, lock, NON_PREDICTIVE, NUMERIC, PASSWORD, PHONENUMBER, SENSITIVE, showCaret, title, UNEDITABLE, URL |
| Fields inherited from class de.enough.polish.ui.FakeStringCustomItem |
|---|
bitMapFont, bitMapFontViewer, clipText, font, text, textColor, textEffect, textHorizontalAdjustment, textLines, textVerticalAdjustment, useSingleLine, xOffset |
| Fields inherited from class javax.microedition.lcdui.CustomItem |
|---|
KEY_PRESS, KEY_RELEASE, KEY_REPEAT, NONE, POINTER_DRAG, POINTER_PRESS, POINTER_RELEASE, TRAVERSE_HORIZONTAL, TRAVERSE_VERTICAL |
| Constructor Summary | |
|---|---|
ChoiceTextField(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
java.lang.String[] availableChoices,
boolean allowFreeTextEntry)
Creates a new ChoiceTextField. |
|
ChoiceTextField(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
java.lang.String[] availableChoices,
boolean allowFreeTextEntry,
boolean appendChoice,
java.lang.String appendChoiceDelimiter)
Creates a new ChoiceTextField. |
|
ChoiceTextField(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
java.lang.String[] availableChoices,
boolean allowFreeTextEntry,
boolean appendChoice,
java.lang.String appendChoiceDelimiter,
Style style)
Creates a new ChoiceTextField. |
|
ChoiceTextField(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
java.lang.String[] availableChoices,
boolean allowFreeTextEntry,
Style style)
Creates a new ChoiceTextField. |
|
| Method Summary | |
|---|---|
void |
animate(long currentTime,
ClippingRegion repaintRegion)
Animates this item. |
protected void |
defocus(Style origStyle)
Removes the focus from this item. |
protected Style |
focus(Style focStyle,
int direction)
Focuses this item. |
int |
getMatchMode()
Retrieves the matching algorithm that is used for finding out whether an available choices matches the input of the user. |
protected boolean |
handleKeyPressed(int keyCode,
int gameAction)
Handles the key-pressed event. |
protected boolean |
handleKeyReleased(int keyCode,
int gameAction)
Handles the key-released event. |
protected boolean |
handlePointerPressed(int x,
int y)
Handles the event when a pointer has been pressed at the specified position. |
protected boolean |
handlePointerReleased(int x,
int y)
Handles the event when a pointer has been released at the specified position. |
protected void |
initContent(int firstLineWidth,
int lineWidth)
Initialises this item. |
void |
notifyStateChanged()
Causes this Item's containing Form to notify
the Item's ItemStateListener. |
void |
paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
Paints the content of this item. |
void |
setChoices(Item[] choices)
Sets the available choices. |
void |
setChoices(java.lang.String[] choices)
Sets the available choices. |
void |
setChoiceTrigger(char choiceTrigger,
boolean allowChoicesBeforeTrigger)
Enables that available choices should (only) be shown after the specified character is entered. |
void |
setMatchMode(int mode)
Sets the matching algorithm that is used for finding out whether an available choices matches the input of the user. |
void |
setStyle(Style style)
Sets the style of this item. |
| Methods inherited from class de.enough.polish.ui.FakeTextFieldCustomItem |
|---|
animate, commandAction, commandAction, createCssSelector, delete, fieldChanged, getCaretPosition, getChars, getConstraints, getDotSeparatedDecimalString, getMaxSize, getString, handleKeyRepeated, insert, insert, insertCharacter, setCaretPosition, setChars, setConstraints, setInitialInputMode, setInputMode, setItemCommandListener, setMaxSize, setString, size |
| Methods inherited from class de.enough.polish.ui.FakeStringCustomItem |
|---|
getFont, getText, hideNotify, releaseResources, setFont, setText, setText, showNotify, toString |
| Methods inherited from class javax.microedition.lcdui.CustomItem |
|---|
getGameAction, getInteractionModes, invalidate, keyPressed, keyReleased, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, sizeChanged, traverse, traverseOut |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MATCH_STARTS_WITH
public static final int MATCH_INDEX_OF
| Constructor Detail |
|---|
public ChoiceTextField(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
java.lang.String[] availableChoices,
boolean allowFreeTextEntry)
label - the labeltext - the current textmaxSize - the maximum size for the inputconstraints - input constraints, TextField.ANY for no constraintsavailableChoices - a list of available texts for the userallowFreeTextEntry - true when the user should be allowed to enter any text that does not match any existing choice
public ChoiceTextField(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
java.lang.String[] availableChoices,
boolean allowFreeTextEntry,
Style style)
label - the labeltext - the current textmaxSize - the maximum size for the inputconstraints - input constraints, TextField.ANY for no constraintsavailableChoices - a list of available texts for the userallowFreeTextEntry - true when the user should be allowed to enter any text that does not match any existing choicestyle - the style for this item
public ChoiceTextField(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
java.lang.String[] availableChoices,
boolean allowFreeTextEntry,
boolean appendChoice,
java.lang.String appendChoiceDelimiter)
label - the labeltext - the current textmaxSize - the maximum size for the inputconstraints - input constraints, TextField.ANY for no constraintsavailableChoices - a list of available texts for the userallowFreeTextEntry - true when the user should be allowed to enter any text that does not match any existing choiceappendChoice - true when the selected choices should be appended to the text rather than replacing the textappendChoiceDelimiter - the character that separates several selections, e.g. '\n' or ';'
public ChoiceTextField(java.lang.String label,
java.lang.String text,
int maxSize,
int constraints,
java.lang.String[] availableChoices,
boolean allowFreeTextEntry,
boolean appendChoice,
java.lang.String appendChoiceDelimiter,
Style style)
label - the labeltext - the current textmaxSize - the maximum size for the inputconstraints - input constraints, TextField.ANY for no constraintsavailableChoices - a list of available texts for the userallowFreeTextEntry - true when the user should be allowed to enter any text that does not match any existing choiceappendChoice - true when the selected choices should be appended to the text rather than replacing the textappendChoiceDelimiter - the character that separates several selections, e.g. "\n" or ";" or null.style - the style for this item| Method Detail |
|---|
protected void initContent(int firstLineWidth,
int lineWidth)
FakeCustomItem
initContent in class FakeTextFieldCustomItemfirstLineWidth - the maximum width of the first linelineWidth - the maximum width of any following linesFakeCustomItem.contentWidth,
FakeCustomItem.contentHeight,
FakeCustomItem.preferredWidth,
FakeCustomItem.preferredHeight
public void setChoiceTrigger(char choiceTrigger,
boolean allowChoicesBeforeTrigger)
choiceTrigger - the trigger for showing choiceallowChoicesBeforeTrigger - true when the user should be able to add choices before he has entered the trigger characterpublic void setChoices(java.lang.String[] choices)
choices - the new choices, null when no choices are givenpublic void setChoices(Item[] choices)
choices - the new choices, null when no choices are availablepublic void setMatchMode(int mode)
mode - the matching mode, the default mode is ChoiceTextField.MATCH_STARTS_WITH, so the user input is compared with the start of the available choices.MATCH_STARTS_WITH,
MATCH_INDEX_OF,
for using complex matching rules,
for using complex matching rulespublic int getMatchMode()
MATCH_STARTS_WITH,
MATCH_INDEX_OF,
for using complex matching rules,
for using complex matching rulesprotected void defocus(Style origStyle)
FakeCustomItem
defocus in class FakeTextFieldCustomItemorigStyle - the original style which will be restored.
public void animate(long currentTime,
ClippingRegion repaintRegion)
FakeCustomItem
animate in class FakeCustomItemcurrentTime - the current time in millisecondsrepaintRegion - the repaint area that needs to be updated when this item is animated#addRelativeRegion(ClippingRegion, int, int, int, int)
protected Style focus(Style focStyle,
int direction)
FakeCustomItem
focus in class FakeTextFieldCustomItemfocStyle - the style which is used to indicate the focused statedirection - the direction from which this item is focused,
either Canvas.UP, Canvas.DOWN, Canvas.LEFT, Canvas.RIGHT or 0.
When 0 is given, the direction is unknown.
protected boolean handleKeyPressed(int keyCode,
int gameAction)
FakeCustomItem
handleKeyPressed in class FakeTextFieldCustomItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
protected boolean handleKeyReleased(int keyCode,
int gameAction)
FakeCustomItem
handleKeyReleased in class FakeTextFieldCustomItemkeyCode - the code of the pressed key, e.g. Canvas.KEY_NUM2gameAction - the corresponding game-action, e.g. Canvas.UP
FakeCustomItem.handleKeyPressed(int, int)
protected boolean handlePointerPressed(int x,
int y)
FakeTextFieldCustomItem
handlePointerPressed in class FakeTextFieldCustomItemx - the x position of the pointer pressingy - the y position of the pointer pressing
this method is used for determining whether the event belongs to this item,
for a helper method for determining whether the event took place into the actual content area,
FakeCustomItem.handleKeyPressed(int, int),
for calculating the horizontal position relative to the content (relX - contentX),
for calculating the vertical position relative to the content (relY - contentY)
protected boolean handlePointerReleased(int x,
int y)
FakeCustomItem
handlePointerReleased in class FakeCustomItemx - the x position of the pointer pressing relative to this item's left positiony - the y position of the pointer pressing relative to this item's top position
this method is used for determining whether the event belongs to this item,
for a helper method for determining whether the event took place into the actual content area,
FakeCustomItem.handleKeyPressed(int, int),
for calculating the horizontal position relative to the content (relX - contentX),
for calculating the vertical position relative to the content (relY - contentY)
public void paintContent(int x,
int y,
int leftBorder,
int rightBorder,
javax.microedition.lcdui.Graphics g)
FakeCustomItem
paintContent in class FakeTextFieldCustomItemx - the left start positiony - the upper start positionleftBorder - the left border, nothing must be painted left of this positionrightBorder - the right border, nothing must be painted right of this positiong - the Graphics on which this item should be painted.public void notifyStateChanged()
FakeCustomItemItem's containing Form to notify
the Item's ItemStateListener.
The application calls this method to inform the
listener on the Item that the Item's
state has been changed in
response to an action. Even though this method simply causes a call
to another part of the application, this mechanism is useful for
decoupling the implementation of an Item (in particular, the
implementation of a CustomItem, though this also applies to
subclasses of other items) from the consumer of the item.
If an edit was performed by invoking a separate screen, and the
editor now wishes to "return" to the form which contained the
selected Item, the preferred method is
Display.setCurrent(Item)
instead of Display.setCurrent(Displayable),
because it allows the
Form to restore focus to the Item
that initially invoked the editor.
In order to make sure that the documented behavior of
ItemStateListener is maintained, it is up to the caller
(application) to guarantee that this function is
not called unless:
Item's value has actually been changed, andItem's APIs The call to ItemStateListener.itemStateChanged
may be delayed in order to be serialized with the event stream.
The notifyStateChanged method does not block awaiting
the completion of the itemStateChanged method.
notifyStateChanged in class FakeCustomItempublic void setStyle(Style style)
FakeCustomItem
setStyle in class FakeTextFieldCustomItemstyle - the new style for this item.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||