|
|||||||||
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); }
Field Summary | |
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 |
static Calculator |
calculator
|
static Calendar |
calendar
|
static byte |
CURRENCY
to be used in the setMode method |
static String |
currencyCharsSet
to be used in the setValidChars method |
static byte |
DATE
to be used in the setMode method |
static String |
dateSet
to be used in the setValidChars method |
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 |
static Keyboard |
keyboard
|
String |
mask
used only to compute the preferred width of this edit. |
static byte |
NORMAL
to be used in the setMode method |
static String |
numbersSet
to be used in the setValidChars method |
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
|
Fields inherited from class waba.ui.Control |
AFTER,
appId,
asContainer,
asWindow,
backColor,
backDis,
BEFORE,
BOTTOM,
CENTER,
enabled,
FILL,
FIT,
fm,
fmH,
focusLess,
font,
foreColor,
foreDis,
height,
LEFT,
parent,
PREFERRED,
RANGE,
RIGHT,
SAME,
TOP,
visible,
width,
x,
x2,
y,
y2 |
Constructor Summary | |
Edit()
Construct an Edit with a default width of 10 chars. |
|
Edit(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)
|
protected void |
draw(Graphics g,
boolean cursorOnly)
|
int[] |
getCursorPos()
Returns an array with the cursor positions. |
String |
getMask()
Deprecated. access the mask member directly |
int |
getPreferredHeight()
Returns the preffered height of this control. |
int |
getPreferredWidth()
Returns the preffered width of this control. |
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 an 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 |
setMask(String mask)
Deprecated. access the mask member directly |
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(String s)
Sets the text displayed in the edit control. |
void |
setValidChars(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,
contains,
createGraphics,
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 |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
toString,
wait,
wait |
Field Detail |
public static Keyboard keyboard
public static Calendar calendar
public static Calculator calculator
public String mask
public boolean hasCursorWhenNotEditable
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 String numbersSet
public static final String currencyCharsSet
public static final 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(String mask)
Method Detail |
public void setCapitaliseMode(byte cap)
public void setKeyboard(byte kbd)
public void setMode(byte mode)
public void setValidChars(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 String getText()
public void setText(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 popupKCC()
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 onEvent(Event event)
event
- the event to processEvent
,
KeyEvent
,
PenEvent
protected void onWindowPaintFinished()
public void onPaint(Graphics g)
g
- the graphics object for drawingGraphics
public String getMask()
public void setMask(String mask)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |