ewe.ui
Class mInput

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.EditControl
              extended byewe.ui.mInput
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, ImageRefresher, Selectable, TimerProc, UIConstants
Direct Known Subclasses:
HexDisplay

public class mInput
extends EditControl
implements TimerProc, Selectable

An mInput is a single line input.

Call getText() and setText() to get/set the text data.

Set isPassword true to indicate that '*' characters should be displayed instead of the input text.

Change the columns value to increase the preferred width of the input. This value is measured in characters.


Field Summary
protected static ImageBuffer blockBuffer
           
 int clicksToFireAction
          You can have the mInput fire an action event when the user single clicks the mInput by setting this value to 1, or double clicks by setting the value to 2.
protected  boolean cursorOn
           
protected  int cursorPos
           
static int DATA_CHANGED_BY_ENTER
          This is a flag used with a generated DataChangeEvent to indicate that the data was changed by the enter key being pressed.
 boolean dataChangeOnEachKey
          If this is true then a DataChange will be fired on each key.
protected  int endSel
           
protected  boolean hasCursor
           
static String hidden
          This String will be used to display characters when the isPassword option is used.
static int inputEdge
          This is the default edge to use on mInputs.
 boolean isPassword
          Set this true so that only '*' characters are displayed.
protected static ImageBuffer itemBuffer
           
protected  int leftMost
           
 int maxLength
          This is the maximum number of allowed characters, a value of -1 (the default) puts no limit on the number of characters.
 int minXScroll
          A percent figure.
protected  int numDisplayed
           
 char passwordCharacter
          This is the password character to use for the input.
 int spacing
           
protected  int startSel
           
 boolean wantReturn
          If this is true then the mInput will fire an action event when enter is pressed, but will not automatically pass focus to the next control as it would usually do.
 
Fields inherited from class ewe.ui.EditControl
blinkId, CASE_LOWER, CASE_NORMAL, CASE_NUMBERS, CASE_SENTENCE, CASE_UPPER, colors, conditionalChar, conditionalCharIndex, doingLocalInput, doingNativeInput, FLAG_INPUT_ON_FOCUS, FLAG_KEEP_FOCUS_AFTER_INPUT, FLAG_PASSIVE, FLAG_USE_NATIVE, inFocus, inputFlags, inputMethod, justGotFocus, oldText, pageColor, startNativeOnPaint, textCase, validator
 
Fields inherited from class ewe.ui.Control
_debug, backGround, beforeRemoved, borderColor, borderStyle, borderWidth, children, columns, constraints, DoPaintMethod, dragging, dragResolution, dragTime, exitKeys, fieldTransfer, font, foreGround, haveNativePaint, height, holdDownPause, holdTick, hotKey, image, lastSelected, listeners, maxHeight, maxWidth, menuState, minHeight, minWidth, modifiers, MyClass, name, next, np, parent, penStatus, popupSound, popupSoundClip, preferredHeight, preferredWidth, prev, prompt, promptControl, rows, ss, standardBorder, standardEdge, startDragResolution, tags, tail, text, toolTip, width, x, y
 
Fields inherited from class ewe.ui.ControlBase
clipItems, clipObject, clipOwner, curPoint, currentPenEvent, debugControl, debugFlag, DidHoldDown, doubleBuffer, doubleClickTime, firstPress, globalDrawFlat, globalEditable, globalEnabled, globalPalmStyle, globalSmallControls, GotPenDown, PenIsOn, pressPoint, TAG_LAST_USER_DATA, TAG_USER_DATA, TAKE_FIRST_PRESS, unnamed, useNativeTextInput
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Fields inherited from interface ewe.fx.ImageRefresher
KEEP_VISIBLE
 
Constructor Summary
mInput()
           
mInput(String txt)
           
 
Method Summary
 boolean acceptsData(Object data, DragContext how)
          This should indicate whether this control will accept the data either via a drag and drop or via a paste operation.
protected  void calculateSizes()
          Override this to calculate the preferred, minimum and maximum size of your control.
 void cursorToEnd()
           
 boolean deleteSelection()
           
protected  void doDragAt(Point p)
           
 void doPaint(Graphics g, Rect area)
           
protected  void doPaintData(Graphics gr)
          Repaint the "data" part of the Control.
protected  boolean doShowMenu(Point p)
          Used to show the menu associated with the Control.
 void dragged(DragContext dc)
          This is called during the drag operation.
 int findPressedChar(Point where)
           
protected  boolean fix()
           
protected  boolean getCharRect(int which, Rect dest)
           
 int getCursorPosition()
           
protected  Rect getDataRect(Rect dest)
          Get the rectangle, relative to the Control, of the area considered to be the "data" part of the control.
 String getDisplay(String s)
          This gets the String to represent on screen the data String provided.
 char getPasswordCharacter()
          If isPassword is false, this returns 0, otherwise it will return the password character to use for display.
 Object getSelection()
           
 Range getSelectionRange()
          Use this to get the selection range.
 void gotFocus(int how)
           
 boolean hasSelection()
           
 void lostFocus(int how)
           
protected  void moveCursorPos(int where, boolean takeSelection)
           
protected  void newCursorPos(int where)
           
protected  void newCursorPos(int where, boolean takeSelection)
           
 void newText(String what, int newCursorPos)
           
 void newText(String what, int newCursorPos, boolean repaintAll)
           
 boolean noSelection()
           
 void onEvent(Event ev)
           
 void onKeyEvent(KeyEvent ev)
           
 boolean paintConditionalChar(Graphics gr, boolean underlined)
           
 void paintCursor(Graphics gr)
           
 boolean paintLastChar(Graphics g)
           
 boolean paintLastChar(Graphics g, boolean eraseIt)
           
 void penDoubleClicked(Point where)
          Called if the Pen or Mouse button is double clicked on the Control.
 void penPressed(Point where)
          Called when the Pen or Mouse button is pressed on the control.
 void penReleased(Point where)
          Called when the Pen or Mouse button is released on the control.
protected  void popupMenuClosed(Menu m)
          This gets closed after the popup menu for the Control has closed.
 boolean replaceSelection(Object with)
           
 void resizeTo(int width, int height)
          This will change the width and height values.
 void selectAll()
           
protected  void setNativeInputFlags(TextInputParameters tip)
           
 void setText(String txt)
           
 void startDragging(DragContext dc)
          This is called to indicate the start of a pen/mouse drag operation.
protected  void startLocalInput(boolean selectAll)
           
 void stopActiveInput()
           
protected  void stopAllInput()
           
 void ticked(int id, int elapsed)
           
 void update()
           
 void updateText(boolean generateEvent)
           
protected  void updateText(boolean generateEvent, boolean fromEnter)
           
 boolean validateText(String what)
          This is used to validate any new text.
 
Methods inherited from class ewe.ui.EditControl
checkInputMethod, checkSipCoverage, dataBeingRemoved, dataTransferCancelled, fixCase, getBestPassiveFlags, getColors, hasChanged, keepConditionalChar, onControlEvent, setConditionalChar, startActiveInput, startNativeInput, takeData, updateData
 
Methods inherited from class ewe.ui.Control
activate, addListener, addTimer, amOnTopFrame, calculateTextSize, cancelCut, cancelHoldDown, canEdit, chainDataChange, change, checkClipboardOperations, checkExitKey, checkMenu, checkMenuKey, checkModifiers, checkPenTransparent, clearTag, clipboardToString, clipboardTransfer, closeMenu, contains, contains, createGraphics, dataAccepted, dataDraggedOff, dataDraggedOver, dataDraggedOver, dataDroppedOn, deactivate, defaultTo, doAction, doActionKey, doBackground, doBorder, doHotKey, doMenu, dontAcceptDrop, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, exitEntry, fillBackground, formClosing, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getBackground, getChildren, getChildrenBackwards, getClipboardMenu, getClipObject, getControlBuffer, getControlBuffer, getDataToCopy, getDataToDragAndDrop, getDim, getDisplayText, getDragAndDropContext, getFont, getFontMetrics, getFontMetrics, getForeground, getFrame, getFrameOrContainer, getGraphics, getImage, getLastSelected, getLocation, getMaximumSize, getMenu, getMinimumSize, getModifiers, getNext, getNextKeyFocus, getParent, getPosInFrame, getPosInParent, getPreferredSize, getPrompt, getPromptText, getRect, getRect, getServer, getSize, getSizes, getSubControls, getTag, getText, getToolTip, getWindow, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, make, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyAction, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, onLabelPenEvent, onPaint, onPenEvent, paintBackground, paintChildren, penClicked, penHeld, penRightReleased, popupBeep, popupMenuEvent, popupMenuEvent, postEvent, recalculatePreferredSize, redisplay, refresh, removeListener, removeTimer, repaint, repaintDataNow, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetRect, restore, scrollAndRepaint, sendToListeners, set, setBorder, setCell, setClipObject, setControl, setCursor, setFixedSize, setFont, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPromptControl, setRect, setRect, setServer, setTag, setTags, setTextSize, setToolTip, show, shown, standardOnKeyEvent, startDragAndDrop, startDragAndDrop, stopDragging, takeFocus, takeFromClipboard, takePromptControl, testDim, toClipboard, toField, toField, toString, toTextData, transferPenPress, transferPenPress, tryDragAndDrop, tryNext, tryStartMenu, willAcceptDrop, willShowFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 

Field Detail

spacing

public int spacing

minXScroll

public int minXScroll
A percent figure. Defaults to 30%


isPassword

public boolean isPassword
Set this true so that only '*' characters are displayed.


clicksToFireAction

public int clicksToFireAction
You can have the mInput fire an action event when the user single clicks the mInput by setting this value to 1, or double clicks by setting the value to 2. A value of 0 (the default) sets the mInput to not fire any actions with mouse clicks.


maxLength

public int maxLength
This is the maximum number of allowed characters, a value of -1 (the default) puts no limit on the number of characters.


wantReturn

public boolean wantReturn
If this is true then the mInput will fire an action event when enter is pressed, but will not automatically pass focus to the next control as it would usually do.


dataChangeOnEachKey

public boolean dataChangeOnEachKey
If this is true then a DataChange will be fired on each key.


inputEdge

public static int inputEdge
This is the default edge to use on mInputs. By default it is EDGE_SUNKEN|BDR_OUTLINE, but you can change it to something different (e.g. BF_BOTTOM - to emulate a PalmOS type input).


DATA_CHANGED_BY_ENTER

public static final int DATA_CHANGED_BY_ENTER
This is a flag used with a generated DataChangeEvent to indicate that the data was changed by the enter key being pressed. This would indicate that an Action event will follow the DataChangeEvent.

See Also:
Constant Field Values

leftMost

protected int leftMost

numDisplayed

protected int numDisplayed

startSel

protected int startSel

endSel

protected int endSel

cursorPos

protected int cursorPos

cursorOn

protected boolean cursorOn

hasCursor

protected boolean hasCursor

passwordCharacter

public char passwordCharacter
This is the password character to use for the input. By default it is '*'


hidden

public static String hidden
This String will be used to display characters when the isPassword option is used.


itemBuffer

protected static ImageBuffer itemBuffer

blockBuffer

protected static ImageBuffer blockBuffer
Constructor Detail

mInput

public mInput()

mInput

public mInput(String txt)
Method Detail

doShowMenu

protected boolean doShowMenu(Point p)
Description copied from class: Control
Used to show the menu associated with the Control. This will be called by tryStartMenu() which is what you should use instead.

Overrides:
doShowMenu in class Control
Parameters:
p - The point where the pen was pressed.
Returns:
true always.

popupMenuClosed

protected void popupMenuClosed(Menu m)
Description copied from class: Control
This gets closed after the popup menu for the Control has closed. You can clear the menu by doing setMenu(null).

Overrides:
popupMenuClosed in class Control

setText

public void setText(String txt)
Overrides:
setText in class Control

calculateSizes

protected void calculateSizes()
Description copied from class: Control
Override this to calculate the preferred, minimum and maximum size of your control. This is only called once unless the modifier flag AlwaysRecalculateSizes is true. During the calculation you will set the variables preferredWidth, preferredHeight, etc. directly.

Overrides:
calculateSizes in class Control

cursorToEnd

public void cursorToEnd()

getDataRect

protected Rect getDataRect(Rect dest)
Description copied from class: Control
Get the rectangle, relative to the Control, of the area considered to be the "data" part of the control. This is only used for Controls with the HasData modifier. These are controls that distinguish between their data (e.g. contained text) and non-data (e.g. border) on-screen display.

Overrides:
getDataRect in class Control
Parameters:
dest - The destination rectangle.
Returns:
The destination rectangle or a new rectangle if the destination is null.

getCharRect

protected boolean getCharRect(int which,
                              Rect dest)

ticked

public void ticked(int id,
                   int elapsed)
Specified by:
ticked in interface TimerProc
Overrides:
ticked in class Control

gotFocus

public void gotFocus(int how)
Overrides:
gotFocus in class Control

stopAllInput

protected void stopAllInput()

lostFocus

public void lostFocus(int how)
Overrides:
lostFocus in class Control

stopActiveInput

public void stopActiveInput()

updateText

public void updateText(boolean generateEvent)

updateText

protected void updateText(boolean generateEvent,
                          boolean fromEnter)

getPasswordCharacter

public char getPasswordCharacter()
If isPassword is false, this returns 0, otherwise it will return the password character to use for display.

Overrides:
getPasswordCharacter in class Control

getDisplay

public String getDisplay(String s)
This gets the String to represent on screen the data String provided. If the mInput is not a password, this will just return the provided String itself. Otherwise it returns a String of "hidden" characters equal in length to the data String.

Parameters:
s - The data String to display.

doPaintData

protected void doPaintData(Graphics gr)
Description copied from class: Control
Repaint the "data" part of the Control. This is only used for Controls with the HasData modifier. These are controls that distinguish between their data (e.g. contained text) and non-data (e.g. border) on-screen display.

Overrides:
doPaintData in class Control
Parameters:
gr - The Graphics object to paint to.

doPaint

public void doPaint(Graphics g,
                    Rect area)
Overrides:
doPaint in class Control

paintCursor

public void paintCursor(Graphics gr)

paintLastChar

public boolean paintLastChar(Graphics g)

paintLastChar

public boolean paintLastChar(Graphics g,
                             boolean eraseIt)

paintConditionalChar

public boolean paintConditionalChar(Graphics gr,
                                    boolean underlined)
Specified by:
paintConditionalChar in class EditControl

fix

protected boolean fix()

validateText

public boolean validateText(String what)
This is used to validate any new text. This implementation will first call the validator's isValidText() method (if a validator has been set) and then it will check that the text does not exceed the maxLength value (if maxLength is not negative).


newText

public void newText(String what,
                    int newCursorPos)

newText

public void newText(String what,
                    int newCursorPos,
                    boolean repaintAll)

moveCursorPos

protected void moveCursorPos(int where,
                             boolean takeSelection)

newCursorPos

protected void newCursorPos(int where,
                            boolean takeSelection)

newCursorPos

protected void newCursorPos(int where)

deleteSelection

public boolean deleteSelection()
Specified by:
deleteSelection in interface Selectable

replaceSelection

public boolean replaceSelection(Object with)
Specified by:
replaceSelection in interface Selectable

getSelection

public Object getSelection()
Specified by:
getSelection in interface Selectable

startLocalInput

protected void startLocalInput(boolean selectAll)
Overrides:
startLocalInput in class EditControl

setNativeInputFlags

protected void setNativeInputFlags(TextInputParameters tip)
Overrides:
setNativeInputFlags in class EditControl

onKeyEvent

public void onKeyEvent(KeyEvent ev)
Overrides:
onKeyEvent in class Control

findPressedChar

public int findPressedChar(Point where)

hasSelection

public boolean hasSelection()
Specified by:
hasSelection in interface Selectable

selectAll

public void selectAll()
Specified by:
selectAll in class EditControl

noSelection

public boolean noSelection()
Specified by:
noSelection in interface Selectable

penPressed

public void penPressed(Point where)
Description copied from class: Control
Called when the Pen or Mouse button is pressed on the control. This is called by the onPenEvent(PenEvent ev) method.

Within this method you can use the Control.currentPenEvent value to find out more about the PenEvent that caused this - including any modifiers (e.g. SHIFT keys) or determine if the left or right mouse button was pressed.

Overrides:
penPressed in class Control
Parameters:
where - The point on the Control where the pen was pressed.

penReleased

public void penReleased(Point where)
Description copied from class: Control
Called when the Pen or Mouse button is released on the control. This is called by the onPenEvent(PenEvent ev) method.

Within this method you can use the Control.currentPenEvent value to find out more about the PenEvent that caused this - including any modifiers (e.g. SHIFT keys) or determine if the left or right mouse button was pressed.

Overrides:
penReleased in class Control
Parameters:
where - The point on the Control where the pen was released.

penDoubleClicked

public void penDoubleClicked(Point where)
Description copied from class: Control
Called if the Pen or Mouse button is double clicked on the Control. This is called by the onPenEvent(PenEvent ev) method.

Within this method you can use the Control.currentPenEvent value to find out more about the PenEvent that caused this - including any modifiers (e.g. SHIFT keys) or determine if the left or right mouse button was pressed.

By default this method simply calls the penClicked() method.

Overrides:
penDoubleClicked in class Control
Parameters:
where - The point on the Control where the pen was double-clicked.

startDragging

public void startDragging(DragContext dc)
Description copied from class: Control
This is called to indicate the start of a pen/mouse drag operation. This will only get called if the WantDrag modifier has been set for this control. Within this method you can call startDragAndDrop() or tryDragAndDrop() to begin a data DragAndDrop operation.

Overrides:
startDragging in class Control
Parameters:
dc - A DragContext indicating information about the dragging.

dragged

public void dragged(DragContext dc)
Description copied from class: Control
This is called during the drag operation. It is also called by default by the startDragging() method if you do not override it.

Overrides:
dragged in class Control
Parameters:
dc - The DragContext for the dragging operation.

doDragAt

protected void doDragAt(Point p)

resizeTo

public void resizeTo(int width,
                     int height)
Description copied from class: Control
This will change the width and height values.

Overrides:
resizeTo in class Control

acceptsData

public boolean acceptsData(Object data,
                           DragContext how)
Description copied from class: Control
This should indicate whether this control will accept the data either via a drag and drop or via a paste operation.

Overrides:
acceptsData in class EditControl

update

public void update()
Overrides:
update in class EditControl

getSelectionRange

public Range getSelectionRange()
Use this to get the selection range. If this returns 0 then there is no selection range.

Returns:
A Range which indicates the first and last index of the selection.

getCursorPosition

public int getCursorPosition()

onEvent

public void onEvent(Event ev)
Specified by:
onEvent in interface EventListener
Overrides:
onEvent in class Control