|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--waba.ui.Control
|
+--waba.ui.Edit
Edit is a text entry control.
Here is an example showing an edit control being used:
public class MyProgram extends MainWindow
{
Edit edit;
public void onStart()
{
edit = new Edit(""); // mask used to compute preferred width - empty = fill width
add(edit,LEFT,TOP);
}
Important: if you wish to open a popup window after a FOCUS_OUT event has occured,
you must open the window with popupModal, never with popupBlockingModal. Otherwise,
the window will be openned twice.
Here's a sample code on how to proceed:
public class Test extends MainWindow
{
Edit ed;
MessageBox mb;
public void onStart()
{
add(ed = new Edit(""), LEFT, CENTER);
add(new Button("btn"), LEFT, AFTER+5);
}
public void onEvent(Event event)
{
switch (event.type)
{
case ControlEvent.FOCUS_OUT:
if (event.target == ed)
{
event.consumed = true; // this is important!
(mb=new MessageBox("Hi","Verinha")).popupModal();
}
break;
case ControlEvent.WINDOW_CLOSED:
if (event.target == mb)
ed.setText("Window closed.");
break;
}
}
}
| Field Summary | |
int |
alignment
Sets the alignment of this Edit, which can be LEFT (default), CENTER or RIGHT. |
static byte |
ALL_LOWER
to be used in the setCapitaliseMode method |
static byte |
ALL_NORMAL
to be used in the setCapitaliseMode method |
static byte |
ALL_UPPER
to be used in the setCapitaliseMode method |
boolean |
autoSelect
If set to true, the text will be auto-selected when the focus enters |
static Calculator |
calculator
|
static Calendar |
calendar
|
protected byte |
capitalise
|
static byte |
CURRENCY
to be used in the setMode method |
static java.lang.String |
currencyCharsSet
to be used in the setValidChars method |
static byte |
DATE
to be used in the setMode method |
static java.lang.String |
dateSet
to be used in the setValidChars method |
boolean |
editable
Specifies if the control accepts input from the user. |
protected boolean |
hasBorder
|
boolean |
hasCursorWhenNotEditable
Set to false if you don't want the cursor to blink when the edit is not editable |
static byte |
KBD_CALCULATOR
The Calculator will be used for this Edit |
static byte |
KBD_CALENDAR
The Calendar will be used for this Edit |
static byte |
KBD_DEFAULT
The default keyboard for the current mode will be used for this Edit |
static byte |
KBD_KEYBOARD
The Keyboard class (or the internal virtual keyboard) will be used for this Edit |
static byte |
KBD_NONE
No keyboard will be popped up for this Edit |
protected byte |
kbdType
|
static Keyboard |
keyboard
|
protected int |
len
|
java.lang.String |
mask
used only to compute the preferred width of this edit. |
protected int |
maxLength
|
static byte |
NORMAL
to be used in the setMode method |
static java.lang.String |
numbersSet
to be used in the setValidChars method |
boolean |
overwrite
Specifies if new chars should overwrite existing ones. |
static byte |
PASSWORD
to be used in the setMode method. |
static byte |
PASSWORD_ALL
to be used in the setMode method. |
protected int |
pushedInsertPos
|
protected int |
pushedStartSelectPos
|
protected int |
pushedxOffset
|
static boolean |
removeFocusOnAction
|
protected java.lang.String |
validChars
|
| Fields inherited from class waba.ui.Control |
AFTER,
appId,
appObj,
asContainer,
asWindow,
backColor,
backDis,
BEFORE,
BOTTOM,
CENTER,
clearValueInt,
clearValueStr,
enabled,
FILL,
FIT,
fm,
fmH,
focusLess,
focusTraversable,
font,
foreColor,
foreDis,
height,
highlightRectsCount,
isHighlighting,
LEFT,
parent,
PREFERRED,
RANGE,
RIGHT,
SAME,
TOP,
uiCE,
uiFlat,
uiPalm,
uiVista,
visible,
width,
x,
x2,
y,
y2 |
| Constructor Summary | |
Edit()
Construct an Edit with a default width of 10 chars. |
|
Edit(java.lang.String mask)
Construct an Edit with the default width computed based in the specified mask and in the control's font. |
|
| Method Summary | |
protected int |
charPos2x(int n)
|
void |
clear()
Clears this control, settings the text to clearValueStr. |
protected void |
draw(Graphics g,
boolean cursorOnly)
|
int[] |
getCursorPos()
Returns an array with the cursor positions. |
byte |
getKeyboardType()
|
int |
getLength()
Returns the length of the text. |
int |
getPreferredHeight()
Returns the preffered height of this control. |
int |
getPreferredWidth()
Returns the preffered width of this control. |
java.lang.String |
getText()
Returns the text displayed in the edit control. |
protected boolean |
isCharValid(char c)
Return true if the given char exists in the set of valid characters for this Edit |
boolean |
isEditable()
Gets if the control accepts input from the user |
protected void |
onBoundsChanged()
Called after a setRect. |
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. |
void |
onEvent(Event event)
Called by the system to pass events to the edit control. |
void |
onPaint(Graphics g)
Called by the system to draw the edit control. |
protected void |
onWindowPaintFinished()
Called after the window has finished a paint. |
protected void |
popPosState()
|
void |
popupKCC()
user method to popup the keyboard/calendar/calculator for this edit. |
protected void |
pushPosState()
|
void |
setCapitaliseMode(byte cap)
Sets the capitalise settings for this Edit. |
void |
setCursorPos(int start,
int end)
Sets the selected text of this Edit (if start ! |
void |
setEditable(boolean on)
Sets if the control accepts input from the user |
void |
setKeyboard(byte kbd)
Used to change the default keyboard to be used with this Edit control. |
void |
setMaxLength(int length)
Sets the desired maximum length for text entered in the Edit. |
void |
setMode(byte mode)
Used to set the valid characters that can be entered by using one of the constants DATE, CURRENCY and NORMAL. |
void |
setText(java.lang.String s)
Sets the text displayed in the edit control. |
void |
setValidChars(java.lang.String validCharsString)
Sets the valid chars that can be entered in this edit (they are converted to uppercase to make the verification easy). if null is passed, any char can be entered. (case insensitive). added by guich |
protected int |
x2charPos(int x)
|
| Methods inherited from class waba.ui.Control |
addTimer,
changeHighlighted,
contains,
createGraphics,
drawHighlight,
getAbsoluteRect,
getBackColor,
getFont,
getFontMetrics,
getForeColor,
getNext,
getParent,
getParentWindow,
getPos,
getRect,
getSize,
isDisplayed,
isEnabled,
isVisible,
onFontChanged,
postEvent,
removeTimer,
repaint,
repaintNow,
requestFocus,
setBackColor,
setBackForeColors,
setEnabled,
setFocusLess,
setFont,
setForeColor,
setRect,
setRect,
setRect,
setVisible,
translateFromOrigin,
uiStyleChanged |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public boolean editable
public boolean overwrite
public int alignment
protected int len
protected boolean hasBorder
protected java.lang.String validChars
public static Keyboard keyboard
public static Calendar calendar
public static Calculator calculator
protected int maxLength
public java.lang.String mask
protected byte capitalise
public static boolean removeFocusOnAction
protected byte kbdType
public boolean hasCursorWhenNotEditable
public boolean autoSelect
public static final byte KBD_NONE
public static final byte KBD_DEFAULT
public static final byte KBD_KEYBOARD
public static final byte KBD_CALCULATOR
public static final byte KBD_CALENDAR
public static final java.lang.String numbersSet
public static final java.lang.String currencyCharsSet
public static final java.lang.String dateSet
public static final byte NORMAL
public static final byte DATE
public static final byte CURRENCY
public static final byte PASSWORD
public static final byte PASSWORD_ALL
public static final byte ALL_NORMAL
public static final byte ALL_UPPER
public static final byte ALL_LOWER
protected int pushedInsertPos
protected int pushedStartSelectPos
protected int pushedxOffset
| Constructor Detail |
public Edit()
public Edit(java.lang.String mask)
| Method Detail |
public void setCapitaliseMode(byte cap)
public void setKeyboard(byte kbd)
public byte getKeyboardType()
public void setMode(byte mode)
public void setValidChars(java.lang.String validCharsString)
protected boolean isCharValid(char c)
public void setMaxLength(int length)
protected void pushPosState()
protected void popPosState()
protected int x2charPos(int x)
protected int charPos2x(int n)
public java.lang.String getText()
public void setText(java.lang.String s)
public void setEditable(boolean on)
public boolean isEditable()
protected void onBoundsChanged()
public int getPreferredWidth()
public int getPreferredHeight()
protected void onColorsChanged(boolean colorsChanged)
protected void draw(Graphics g,
boolean cursorOnly)
public void setCursorPos(int start,
int end)
setCursorPos(-1,0).
Note: if you're setting the cursor position before the edit is drawn for the first
time, the edit will not be scrolled if the end position goes beyond the limits.
Important! No bounds checking is made. Be sure to not call this method with invalid positions!
Example:
ed.setText("1234567890123456");
ed.setCursorPos(3,14);
ed.requestFocus();
public int[] getCursorPos()
int []cursorPos = ed.getCursorPos();
int start = cursorPos[0];
int end = cursorPos[1];
String text = ed.getText();
if (start != -1) // is the text selected?
{
String selectedText = text.substring(start,end);
...
public void popupKCC()
public void onEvent(Event event)
event - the event to processEvent,
KeyEvent,
PenEventprotected void onWindowPaintFinished()
public void onPaint(Graphics g)
g - the graphics object for drawingGraphicspublic int getLength()
public void clear()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||