|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swt.widgets.Widget org.eclipse.swt.widgets.Control org.eclipse.ercp.swt.mobile.ConstrainedText
A single-line Text control which constrains the user input by styles.
This control limits the characters that users can enter by the styles to make data entry more efficient. This capability is usually implemented by the underlying platform and applications are not allowed to change or override the constraints. An IllegalArgumentException will be thrown if illegal content is set programmatically by applications.
Field Summary | |
static int |
DECIMAL
Decimal input style allows the input of numeric values with optional decimal fractions, for example, "-123", "0.123", or ".5" are all valid input. |
static int |
NUMERIC
Numeric input style allows the input of numeric values. |
static int |
PHONENUMBER
Phone number input style allows the input of numeric values with optional phone specific characters like "+", "* and "#". |
Constructor Summary | |
ConstrainedText(Composite parent,
int style,
int constrainedStyle)
Constructs a new instance of this class given its parent, a style value describing behaviour and appearance, and an additional constrained style specifying the input styles defined above. |
Method Summary | |
void |
addModifyListener(ModifyListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by sending it one of the messages defined in the ModifyListener interface. |
void |
addSelectionListener(SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the control is selected, by sending it one of the messages defined in the SelectionListener interface. |
void |
append(java.lang.String string)
Appends a string. |
void |
clearSelection()
Clears the selection. |
void |
copy()
Copies the selected text. |
void |
cut()
Cuts the selected text. |
int |
getCaretPosition()
Gets the position of the caret. |
int |
getCharCount()
Gets the number of characters. |
boolean |
getEditable()
Gets the editable state. |
java.lang.String |
getText()
Gets the widget text. |
int |
getTextLimit()
Returns the maximum number of characters that the receiver is capable of holding. |
void |
insert(java.lang.String string)
Inserts a string after the caret position. |
void |
paste()
Pastes text from clipboard. |
void |
removeModifyListener(ModifyListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver's text is modified. |
void |
removeSelectionListener(SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the control is selected. |
void |
selectAll()
Selects all the text in the receiver. |
void |
setEditable(boolean editable)
Sets the editable state. |
void |
setSelection(int start)
Sets the selection. |
void |
setSelection(int start,
int end)
Sets the selection. |
void |
setText(java.lang.String text)
Sets the initial contents of the receiver to the given string. |
void |
setTextLimit(int limit)
Sets the maximum number of characters that the receiver is capable of holding to be the argument. |
void |
showSelection()
Shows the selection. |
Methods inherited from class org.eclipse.swt.widgets.Widget |
addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int NUMERIC
Value 1
is assigned to NUMERIC
.
public static final int DECIMAL
Value 2
is assigned to DECIMAL
.
public static final int PHONENUMBER
Value 4
is assigned to PHONENUMBER
.
Constructor Detail |
public ConstrainedText(Composite parent, int style, int constrainedStyle)
The style value is either one of the style constants defined in class
SWT
which is applicable to instances of this class, or
must be built by bitwise OR 'ing together (that is, using the
int
"|" operator) two or more of those SWT
style constants. Style bits are also inherited from superclasses. The
class description lists the constrained style constants that can be set
in constrainedStyle.
parent
- a composite control which will be the parent of the new
instance (cannot be null)style
- the style of control to constructconstrainedStyle
- the constrained style
java.lang.IllegalArgumentException
- SWTException
- NUMERIC
,
DECIMAL
,
PHONENUMBER
Method Detail |
public void addModifyListener(ModifyListener listener)
ModifyListener
interface.
listener
- the listener which should be notified
java.lang.IllegalArgumentException
- SWTException
- ModifyListener
,
removeModifyListener(org.eclipse.swt.events.ModifyListener)
public void addSelectionListener(SelectionListener listener)
SelectionListener
interface.
widgetSelected
is not called for this control.
widgetDefaultSelected
is called when a selection key is
pressed.
listener
- the listener which should be notified
java.lang.IllegalArgumentException
- SWTException
- SelectionListener
,
removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,
SelectionEvent
public void append(java.lang.String string)
The new text is appended to the text at the end of the widget. The excessive characters will be truncated if the length exceeds the maximum number of characters that the receiver is capable of holding.
string
- the string to be appended
java.lang.IllegalArgumentException
- SWTException
- public void clearSelection()
SWTException
- public void copy()
The current selection is copied to the clipboard.
SWTException
- public void cut()
The current selection is first copied to the clipboard and then deleted from the widget.
SWTException
- public int getCaretPosition()
The character position of the caret is returned.
SWTException
- public int getCharCount()
SWTException
- public boolean getEditable()
SWTException
- public java.lang.String getText()
The text for a text widget is the characters in the widget.
SWTException
- public int getTextLimit()
If this has not been changed by setTextLimit()
, it will
be the constant Text.LIMIT
.
SWTException
- public void insert(java.lang.String string)
The old selection is replaced with the new text. The excessive characters will be truncated if the length exceeds the maximum number of characters that the receiver is capable of holding.
string
- the string value.
java.lang.IllegalArgumentException
- SWTException
- public void paste()
The selected text is deleted from the widget and new text inserted from the clipboard. The excessive characters will be truncated if the length exceeds the maximum number of characters that the receiver is capable of holding.
java.lang.IllegalArgumentException
- SWTException
- public void removeModifyListener(ModifyListener listener)
listener
- the listener which should no longer be notified
java.lang.IllegalArgumentException
- SWTException
- ModifyListener
,
addModifyListener(org.eclipse.swt.events.ModifyListener)
public void removeSelectionListener(SelectionListener listener)
listener
- the listener which should be notified
java.lang.IllegalArgumentException
- SWTException
- SelectionListener
,
addSelectionListener(org.eclipse.swt.events.SelectionListener)
public void selectAll()
SWTException
- public void setEditable(boolean editable)
editable
- the new editable state
SWTException
- public void setSelection(int start)
Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions that address character position such as getText () that use the regular array indexing rules.
start
- new caret position
java.lang.IllegalArgumentException
- SWTException
- public void setSelection(int start, int end)
Indexing is zero based. The range of a selection is from 0..N where N is the number of characters in the widget.
Text selections are specified in terms of caret positions. In a text widget that contains N characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions that address character position such as getText () that use the usual array indexing rules.
start
- the start of the rangeend
- the end of the range
java.lang.IllegalArgumentException
- SWTException
- public void setText(java.lang.String text)
It is not recommended to set the initial contents especially when the style is PHONENUMBER because an IllegalArgumentException will be thrown when the string format does not match the present locale-specific format.
text
- the new text
java.lang.IllegalArgumentException
- SWTException
- public void setTextLimit(int limit)
Instead of trying to set the text limit to zero, consider creating a read-only text widget.
To reset this value to the default, use
setTextLimit(Text.LIMIT)
.
limit
- new text limit
java.lang.IllegalArgumentException
- SWTException
- Text.LIMIT
public void showSelection()
If the selection is already showing in the receiver, this method simply returns. Otherwise, lines are scrolled until the selection is visible.
SWTException
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |