totalcross.ui
Class ComboBoxEditable

totalcross.lang.Object
  extended by totalcross.ui.gfx.GfxSurface
      extended by totalcross.ui.Control
          extended by totalcross.ui.Container
              extended by totalcross.ui.ComboBox
                  extended by totalcross.ui.ComboBoxEditable
All Implemented Interfaces:
KeyListener, PressListener

public class ComboBoxEditable
extends ComboBox
implements PressListener, KeyListener

The ComboBoxEditable is a control usually used as an Edit that holds old typed values. When the user types a word, it is automatically selected in the ComboBox. Here's a sample of how to use it:

   totalcross.lang.String[] items = {"Ana","Barbara","Raul","Marcelo","Eduardo","Denise","Michelle","Guilherme","Vera","Dulce","Leonardo","Andre","Gustavo","Anne","Renato","Zelia","Helio"};
   ComboBoxEditable cbe = new ComboBoxEditable(items);
   cbe.qsort();
   add(cbe, LEFT,BOTTOM-100);
 


Field Summary
 Edit edit
          The edit used in this ComboBox.
 
Fields inherited from class totalcross.ui.ComboBox
fullHeight, fullWidth, pop
 
Fields inherited from class totalcross.ui.Container
alwaysEraseBackground, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_SIMPLE, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, nextTransitionEffect, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_NONE, TRANSITION_OPEN, transitionEffect
 
Fields inherited from class totalcross.ui.Control
AFTER, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, CENTER, CENTER_OF, clearValueInt, clearValueStr, enabled, enableUpdateScreen, FILL, FIT, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, foreColor, height, isHighlighting, KEEP, LEFT, onEventFirst, parent, PREFERRED, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, setFont, setH, setRel, setW, setX, setY, TOP, transparentBackground, uiCE, uiFlat, uiPalm, uiVista, visible, width, WILL_RESIZE, x, y
 
Constructor Summary
ComboBoxEditable()
           
ComboBoxEditable(ComboBoxDropDown userPopList)
           
ComboBoxEditable(ListBox userListBox)
           
ComboBoxEditable(Object[] items)
           
 
Method Summary
 void actionkeyPressed(KeyEvent e)
          An ACTION_KEY_PRESS event was dispatched.
 void controlPressed(ControlEvent e)
          A PRESSED event was dispatched.
protected  void drawSelectedItem(Graphics g)
           
 void getFocusableControls(Vector v)
          Get a list of child controls of this container which are focus candidates
 Control handleGeographicalFocusChangeKeys(KeyEvent ke)
          Used by the main event loop to give the currently focused control an opportunity to act directly on the KeyEvent.
 void keyPressed(KeyEvent e)
          A KEY_PRESS event was dispatched.
protected  void onBoundsChanged(boolean screenChanged)
          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 e)
          Called to process key, pen, control and other posted events.
protected  void onFontChanged()
          Passes the font to the pop list
 void popup()
          Pops up the ComboBoxDropDown
 void setAutoAdd(boolean on, boolean keepSorted)
          Set to true to add automatically new names that were typed in the edit.
 void specialkeyPressed(KeyEvent ke)
          A SPECIAL_KEY_PRESS event was dispatched.
 void unpop()
          Closes the open ListBox.
 
Methods inherited from class totalcross.ui.ComboBox
add, add, add, add, clear, enableHorizontalScroll, getItemAt, getItems, getListBox, getPreferredHeight, getPreferredWidth, getSelectedIndex, getSelectedItem, indexOf, insert, onPaint, qsort, qsort, remove, remove, remove, removeAll, selectLast, setBackForeItemColors, setCursorColor, setItemAt, setSelectedIndex, setSelectedItem, setSelectedItemStartingWith, size, updatePopRect
 
Methods inherited from class totalcross.ui.Container
add, add, add, add, broadcastEvent, findChild, findNearestChild, findNextFocusControl, getBorderStyle, getChildren, getClientRect, getClientRect, getInsets, incLastX, incLastY, initUI, onAddAgain, onRemove, paintChildren, resize, resizeHeight, resizeWidth, setBorderStyle, setEnabled, setHighlighting, setInsets, swapToTopmostWindow
 
Methods inherited from class totalcross.ui.Control
_onEvent, addFocusListener, addGridListener, addHighlightListener, addKeyListener, addPenListener, addPressListener, addTimer, addTimer, addTimerListener, addWindowListener, changeHighlighted, contains, getAbsoluteRect, getBackColor, getEventListeners, getFont, getForeColor, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getWidth, getX, getX2, getY, getY2, isDisplayed, isEnabled, isInsideOrNear, isVisible, isVisibleAndInside, onWindowPaintFinished, postEvent, postPressedEvent, removeFocusListener, removeGridListener, removeHighlightListener, removeKeyListener, removePenListener, removePressListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, requestFocus, setBackColor, setBackForeColors, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setRect, setVisible, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary
 
Methods inherited from class totalcross.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

edit

public Edit edit
The edit used in this ComboBox. You can customize it if you need.

Constructor Detail

ComboBoxEditable

public ComboBoxEditable()

ComboBoxEditable

public ComboBoxEditable(Object[] items)

ComboBoxEditable

public ComboBoxEditable(ListBox userListBox)

ComboBoxEditable

public ComboBoxEditable(ComboBoxDropDown userPopList)
Method Detail

setAutoAdd

public void setAutoAdd(boolean on,
                       boolean keepSorted)
Set to true to add automatically new names that were typed in the edit.

Parameters:
on - Flag indicating if autoAdd must be set
keepSorted - If the list must be sorted after a new item is added by the autoAdd.

onFontChanged

protected void onFontChanged()
Description copied from class: ComboBox
Passes the font to the pop list

Overrides:
onFontChanged in class ComboBox

onColorsChanged

protected void onColorsChanged(boolean colorsChanged)
Description copied from class: Control
Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. If colorsChanged is true, it was called from setForeColor/setBackColor/Container.add; otherwise, it was called from setEnabled

Overrides:
onColorsChanged in class ComboBox

onBoundsChanged

protected void onBoundsChanged(boolean screenChanged)
Description copied from class: Control
Called after a setRect.

Overrides:
onBoundsChanged in class ComboBox
Parameters:
screenChanged - If the bounds were changed due to a screen change (rotation, collapse)

onEvent

public void onEvent(Event e)
Description copied from class: Control
Called to process key, pen, control and other posted events.

Overrides:
onEvent in class ComboBox
Parameters:
e - the event to process
See Also:
Event, KeyEvent, PenEvent

popup

public void popup()
Description copied from class: ComboBox
Pops up the ComboBoxDropDown

Overrides:
popup in class ComboBox

unpop

public void unpop()
Closes the open ListBox.

Overrides:
unpop in class ComboBox

drawSelectedItem

protected void drawSelectedItem(Graphics g)
Overrides:
drawSelectedItem in class ComboBox

controlPressed

public void controlPressed(ControlEvent e)
Description copied from interface: PressListener
A PRESSED event was dispatched.

Specified by:
controlPressed in interface PressListener
See Also:
ControlEvent

actionkeyPressed

public void actionkeyPressed(KeyEvent e)
Description copied from interface: KeyListener
An ACTION_KEY_PRESS event was dispatched.

Specified by:
actionkeyPressed in interface KeyListener
See Also:
KeyEvent

keyPressed

public void keyPressed(KeyEvent e)
Description copied from interface: KeyListener
A KEY_PRESS event was dispatched.

Specified by:
keyPressed in interface KeyListener
See Also:
KeyEvent

specialkeyPressed

public void specialkeyPressed(KeyEvent ke)
Description copied from interface: KeyListener
A SPECIAL_KEY_PRESS event was dispatched.

Specified by:
specialkeyPressed in interface KeyListener
See Also:
KeyEvent

getFocusableControls

public void getFocusableControls(Vector v)
Description copied from class: Container
Get a list of child controls of this container which are focus candidates

Overrides:
getFocusableControls in class ComboBox
Parameters:
v - A vector into which to add the focus candidates.

handleGeographicalFocusChangeKeys

public Control handleGeographicalFocusChangeKeys(KeyEvent ke)
Description copied from class: Control
Used by the main event loop to give the currently focused control an opportunity to act directly on the KeyEvent.

Overrides:
handleGeographicalFocusChangeKeys in class ComboBox
Parameters:
ke - The KeyEvent to be processed
Returns:
The control that should get focus as a result of this KeyEvent. Null if this control did not handle the KeyEvent.
See Also:
Settings.geographicalFocus