org.xith3d.ui.hud.widgets
Class TextField

java.lang.Object
  extended by org.xith3d.ui.hud.base.Widget
      extended by org.xith3d.ui.hud.base.BackgroundSettableWidget
          extended by org.xith3d.ui.hud.widgets.Label
              extended by org.xith3d.ui.hud.widgets.TextField
All Implemented Interfaces:
org.jagatoo.datatypes.Enableable, org.jagatoo.datatypes.NamableObject, org.jagatoo.datatypes.NamedObject, org.openmali.types.twodee.Positioned2f, org.openmali.types.twodee.Positioned2fRO, org.openmali.types.twodee.Sized2f, org.openmali.types.twodee.Sized2fRO, AutoSizable, PaddingSettable, TextWidget

public class TextField
extends Label

A TextField is a Widget that allows for editing a single line of text.


Nested Class Summary
static class TextField.Description
           
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.BackgroundSettableWidget
BackgroundSettableWidget.BackgroundSettableDescriptionBase
 
Nested classes/interfaces inherited from class org.xith3d.ui.hud.base.Widget
Widget.DescriptionBase
 
Field Summary
 
Fields inherited from class org.xith3d.ui.hud.widgets.Label
DEFAULT_HEAVYWEIGHT
 
Fields inherited from class org.xith3d.ui.hud.base.Widget
transformHeight_Pixels2HUD, transformWidth_Pixels2HUD
 
Constructor Summary
TextField(boolean isHeavyWeight, float width, float height)
          Creates a new TextField with the given width and height and no text initially.
TextField(boolean isHeavyWeight, float width, float height, java.lang.String text)
          Creates a new TextField with the given width and height and no text initially.
TextField(boolean isHeavyWeight, float width, float height, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color, TextAlignment alignment)
          Creates a new TextField with the given width, height and z-index.
TextField(boolean isHeavyWeight, float width, float height, java.lang.String text, TextField.Description textFieldDesc)
          Creates a new Label with the given width, height and z-index.
TextField(float width, float height)
          Creates a new TextField with the given width and height and no text initially.
TextField(float width, float height, java.lang.String text)
          Creates a new TextField with the given width and height and no text initially.
TextField(float width, float height, java.lang.String text, HUDFont font, org.openmali.vecmath2.Colorf color, TextAlignment alignment)
          Creates a new TextField with the given width, height and z-index.
TextField(float width, float height, java.lang.String text, TextField.Description textFieldDesc)
          Creates a new Label with the given width, height and z-index.
 
Method Summary
 void addTextFieldListener(TextFieldListener l)
          Adds a listener, that is notified of special TextField events.
protected  boolean blocksFocusMoveDeviceComponent(org.jagatoo.input.devices.components.DeviceComponent dc)
          Checks, if this Widget blocks the given DeviceComponent for focus-moves.
protected  void drawWidget(Texture2DCanvas texCanvas, int offsetX, int offsetY, int width, int height, boolean drawsSelf)
           
 int getCaretPosition()
           
 java.lang.String getDisplayedText()
          
 char getEchoChar()
           
 char[] getIgnoredChars()
           
protected  void init()
          This method is called when the WidgetContainer is set.
 boolean isEchoMode()
           
 boolean isEditable()
           
protected  void onAttachedToHUD(HUD hud)
          This event is fired, when this Widget is added to the HUD live Widget hierarchy.
protected  void onDetachedFromHUD(HUD hud)
          This event is fired, when this Widget is removed from the HUD live Widget hierarchy.
protected  void onFocusGained()
          This event is fired, when the focus is gained to a Widget.
protected  void onFocusLost()
          This event is fired, when the focus is lost by a Widget.
protected  void onKeyPressed(org.jagatoo.input.devices.components.Key key, int modifierMask, long when)
          This event is fired, when a key is pressed on a focused Widget.
protected  void onKeyTyped(char ch, int modifierMask, long when)
          This event is fired when a key is typed on the keyboard.
protected  void onSizeChanged(float oldWidth, float oldHeight, float newWidth, float newHeight)
          
 void removeTextFieldListener(TextFieldListener l)
          Removes a TextFieldListener from the list.
 void setCaretPosition(int pos)
           
 void setEchoChar(char echoChar)
          Sets the character to replace each character of the TextField's text with when in echo-mode.
 void setEchoMode(boolean echoMode)
          Enables/Disables the echo-mode.
 void setEchoMode(boolean echoMode, char echoChar)
          Enables/Disables the echo-mode.
 void setEditable(boolean editable)
          Enables or disables the editability of this TextField.
 void setFont(HUDFont font)
          Sets the new Font to be used
 void setIgnoredChars(char... ignoredChars)
          Sets the array of chars ignored by this TextField.
 void setText(java.lang.String text)
          Sets the new text to be displayed
protected  void updateText()
          
 
Methods inherited from class org.xith3d.ui.hud.widgets.Label
drawIcon, drawText, getAlignment, getFont, getFont, getFontColor, getFontColor, getFontColorDisabled, getFontDisabled, getIcon, getIconGap, getMinimalHeight, getMinimalSize, getMinimalWidth, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getText, getTextOffsetX, getTextOffsetY, initSize, isAutoSizeEnabled, isEnabled, prepareText, setAlignment, setAutoSizeEnabled, setEnabled, setEnabledImpl, setFontColor, setFontColorDisabled, setFontDisabled, setIcon, setIcon, setIconGap, setMinimalSize, setPadding, setPadding, setText, setText, setTextOffset
 
Methods inherited from class org.xith3d.ui.hud.base.BackgroundSettableWidget
drawBackground, getBackgroundColor, getBackgroundTexture, getBackgroundTileMode, setBackground, setBackground, setBackground, setBackgroundColor, setBackgroundTexture, setBackgroundTexture, setBackgroundTexture, setBackgroundTexture, setBackgroundTileMode, setNoBackground
 
Methods inherited from class org.xith3d.ui.hud.base.Widget
addContainerListener, addControllerListener, addFocusListener, addInputListener, addKeyboardListener, addLocationListener, addMouseListener, addSizeListener, addVisibilityListener, bindToGlobalMouseMovement, calculateTransformHeight_Pixels2HUD, calculateTransformWidth_Pixels2HUD, compareAbsZIndex, createShape, detach, drawAndUpdateWidget, drawBorder, drawWidgetAfterWidgetAssembler, drawWidgetContents, getAbsoluteLocationOnHUD_, getAspect, getAssembly, getBorder, getContainer, getContentAspect, getContentHeight, getContentHeightPX, getContentLeftPX, getContentOffset, getContentTopPX, getContentWidth, getContentWidthPX, getContextMenu, getCursor, getEqualHeight_, getEqualWidth_, getForcedRedrawFrequency, getHeight, getHeightPX, getHUD, getLeft, getLevel, getLocation, getLocation, getLocationHUD2Pixels_, getLocationHUD2SG_, getLocationPixels2HUD_, getLocationSG2HUD_, getMaxRedrawFrequency, getMinHeight, getMinWidth, getName, getParentWindow, getPickHeight, getPickWidth, getRelLocationHUD2Pixels_, getRootHostWidget, getShape, getSize, getSizeHUD2Pixels_, getSizeHUD2SG_, getSizeOfPixels_, getSizePixels2HUD_, getSizeSG2HUD_, getToolTip, getTop, getTransparency, getUserObject, getWidgetAssembler, getWidth, getWidthPX, getZIndex, hasDropShadow, hasFocus, hasFocus, hasToolTip, isAHostedWidgetDirty, isClickable, isDraggable, isFocussable, isHeavyWeight, isHovered, isInitialized, isInitializing, isPickable, isThisWidgetDirty, isVisible, notifyOnDragStopped, onAttachedToContainer, onControllerAxisChanged, onControllerButtonPressed, onControllerButtonReleased, onDetachedFromContainer, onInputStateChanged, onKeyReleased, onLocationChanged, onMouseButtonPressed, onMouseButtonReleased, onMouseEntered, onMouseExited, onMouseMoved, onMouseStopped, onMouseWheelMoved, onVisibilityChanged, pick, pickConditionsMatch, removeContainerListener, removeControllerListener, removeFocusListener, removeInputListener, removeKeyboardListener, removeLocationListener, removeMouseListener, removeSizeListener, removeVisibilityListener, requestFocus, resetWidgetDirty, setBorder, setBorder, setClickable, setContentClipRect, setContextMenu, setCursor, setDraggable, setFocussable, setForcedRedrawFrequency, setHasDropShadow, setHeight, setHostedWidgetDirty, setHostTextureDirty, setHostTextureDirty, setHostWidget, setLocation, setLocation, setLocation, setMaxRedrawFrequency, setName, setPickable, setSize, setSize, setSize, setSize, setTextureDirty, setTextureDirty, setToolTip, setTransparency, setTransparency, setUserObject, setVisible, setWidgetDirty, setWidth, setZIndex, startDragging, toString, update, updateAbsZIndex, updateSizeFactors, updateTranslation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextField

public TextField(boolean isHeavyWeight,
                 float width,
                 float height,
                 java.lang.String text,
                 TextField.Description textFieldDesc)
Creates a new Label with the given width, height and z-index.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
text - the text to display in this TextWidget
textFieldDesc - a LabelDescription instance holding information about font, color, alignment and background-texture

TextField

public TextField(boolean isHeavyWeight,
                 float width,
                 float height,
                 java.lang.String text,
                 HUDFont font,
                 org.openmali.vecmath2.Colorf color,
                 TextAlignment alignment)
Creates a new TextField with the given width, height and z-index.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
text - the text to display in this TextWidget
font - the Font to be used for the text
color - the color to be used
alignment - the horizontal and vertical alignment

TextField

public TextField(boolean isHeavyWeight,
                 float width,
                 float height,
                 java.lang.String text)
Creates a new TextField with the given width and height and no text initially.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget
text - the text to display in this TextWidget

TextField

public TextField(boolean isHeavyWeight,
                 float width,
                 float height)
Creates a new TextField with the given width and height and no text initially.

Parameters:
isHeavyWeight -
width - the new width of this Widget
height - the new height of this Widget

TextField

public TextField(float width,
                 float height,
                 java.lang.String text,
                 TextField.Description textFieldDesc)
Creates a new Label with the given width, height and z-index.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
text - the text to display in this TextWidget
textFieldDesc - a LabelDescription instance holding information about font, color, alignment and background-texture

TextField

public TextField(float width,
                 float height,
                 java.lang.String text,
                 HUDFont font,
                 org.openmali.vecmath2.Colorf color,
                 TextAlignment alignment)
Creates a new TextField with the given width, height and z-index.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
text - the text to display in this TextWidget
font - the Font to be used for the text
color - the color to be used
alignment - the horizontal and vertical alignment

TextField

public TextField(float width,
                 float height,
                 java.lang.String text)
Creates a new TextField with the given width and height and no text initially.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
text - the text to display in this TextWidget

TextField

public TextField(float width,
                 float height)
Creates a new TextField with the given width and height and no text initially.

Parameters:
width - the new width of this Widget
height - the new height of this Widget
Method Detail

addTextFieldListener

public void addTextFieldListener(TextFieldListener l)
Adds a listener, that is notified of special TextField events.

Parameters:
l -

removeTextFieldListener

public void removeTextFieldListener(TextFieldListener l)
Removes a TextFieldListener from the list.

Parameters:
l -

setEditable

public void setEditable(boolean editable)
Enables or disables the editability of this TextField. If not editable, no key-events will be processed and the carret won't be visible.

Parameters:
editable -

isEditable

public boolean isEditable()
Returns:
the editability of this TextField. If not editable, no key-events will be processed and the carret won't be visible.

setCaretPosition

public void setCaretPosition(int pos)

getCaretPosition

public final int getCaretPosition()

setEchoChar

public void setEchoChar(char echoChar)
Sets the character to replace each character of the TextField's text with when in echo-mode.

Parameters:
echoChar -

getEchoChar

public final char getEchoChar()
Returns:
the character to replace each character of the TextField's text with when in echo-mode.

setEchoMode

public void setEchoMode(boolean echoMode,
                        char echoChar)
Enables/Disables the echo-mode.
In echo-mode each character of the TextField's text will be replaced with the echo char.

Parameters:
echoMode -
echoChar -

setEchoMode

public void setEchoMode(boolean echoMode)
Enables/Disables the echo-mode.
In echo-mode each character of the TextField's text will be replaced with the echo char.

Parameters:
echoMode -

isEchoMode

public boolean isEchoMode()
Returns:
the echo-mode.
In echo-mode each character of the TextField's text will be replaced with the echo char.

setIgnoredChars

public void setIgnoredChars(char... ignoredChars)
Sets the array of chars ignored by this TextField.

Parameters:
ignoredChars -

getIgnoredChars

public char[] getIgnoredChars()
Returns:
the array of chars ignored by this TextField.

getDisplayedText

public java.lang.String getDisplayedText()

Overrides:
getDisplayedText in class Label
Returns:
the text, that is actually displayed on the Label.

updateText

protected void updateText()

Overrides:
updateText in class Label

setText

public void setText(java.lang.String text)
Sets the new text to be displayed

Specified by:
setText in interface TextWidget
Overrides:
setText in class Label
Parameters:
text - the new Text

setFont

public void setFont(HUDFont font)
Sets the new Font to be used

Specified by:
setFont in interface TextWidget
Overrides:
setFont in class Label
Parameters:
font - the new Font

blocksFocusMoveDeviceComponent

protected boolean blocksFocusMoveDeviceComponent(org.jagatoo.input.devices.components.DeviceComponent dc)
Checks, if this Widget blocks the given DeviceComponent for focus-moves.

Overrides:
blocksFocusMoveDeviceComponent in class Widget
Returns:
Widget blocks the queried DeviceComponent?

onKeyPressed

protected void onKeyPressed(org.jagatoo.input.devices.components.Key key,
                            int modifierMask,
                            long when)
This event is fired, when a key is pressed on a focused Widget.

Overrides:
onKeyPressed in class Widget
Parameters:
key - the key that was pressed
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

onKeyTyped

protected void onKeyTyped(char ch,
                          int modifierMask,
                          long when)
This event is fired when a key is typed on the keyboard.

Overrides:
onKeyTyped in class Widget
Parameters:
ch - the typed key's character
modifierMask - the mask of modifier keys
when - the keyevent's timestamp

onSizeChanged

protected void onSizeChanged(float oldWidth,
                             float oldHeight,
                             float newWidth,
                             float newHeight)

Overrides:
onSizeChanged in class Label

onFocusGained

protected void onFocusGained()
This event is fired, when the focus is gained to a Widget.

Overrides:
onFocusGained in class Widget

onFocusLost

protected void onFocusLost()
This event is fired, when the focus is lost by a Widget.

Overrides:
onFocusLost in class Widget

onAttachedToHUD

protected void onAttachedToHUD(HUD hud)
This event is fired, when this Widget is added to the HUD live Widget hierarchy.

Overrides:
onAttachedToHUD in class Label
Parameters:
hud - the HUD, the Widget is added to

onDetachedFromHUD

protected void onDetachedFromHUD(HUD hud)
This event is fired, when this Widget is removed from the HUD live Widget hierarchy.

Overrides:
onDetachedFromHUD in class Widget
Parameters:
hud - the HUD, the Widget is removed from

drawWidget

protected void drawWidget(Texture2DCanvas texCanvas,
                          int offsetX,
                          int offsetY,
                          int width,
                          int height,
                          boolean drawsSelf)
Overrides:
drawWidget in class Label

init

protected void init()
This method is called when the WidgetContainer is set.

Overrides:
init in class Label