PulpCore

pulpcore.sprite
Class TextField

java.lang.Object
  extended by pulpcore.sprite.Sprite
      extended by pulpcore.sprite.TextField
All Implemented Interfaces:
PropertyListener

public class TextField
extends Sprite

The TextField is a Sprite that behaves like a common UI text input field. It handles selection, cut, copy, paste, keyboard traversal and mouse input. By default, a TextField's cursor is Input.CURSOR_TEXT.


Field Summary
 Color caretColor
          The caret color.
 Color selectionColor
          The highlight color to use when text is selected.
 
Fields inherited from class pulpcore.sprite.Sprite
alpha, angle, CENTER, DEFAULT, EAST, enabled, height, NORTH, NORTH_EAST, NORTH_WEST, pixelSnapping, SOUTH, SOUTH_EAST, SOUTH_WEST, visible, WEST, width, x, y
 
Constructor Summary
TextField(CoreFont font, CoreFont selectionFont, String text, double x, double y)
           
TextField(CoreFont font, CoreFont selectionFont, String text, double x, double y, double w, double h)
          If height < 0, the height is automatically set to fit the font height.
TextField(CoreFont font, CoreFont selectionFont, String text, int x, int y)
           
TextField(CoreFont font, CoreFont selectionFont, String text, int x, int y, int w, int h)
          If height < 0, the height is automatically set to fit the font height.
TextField(double x, double y, double w, double h)
          If height < 0, the height is automatically set to fit the font height.
TextField(int x, int y, int w, int h)
          If height < 0, the height is automatically set to fit the font height.
TextField(String text, double x, double y)
           
TextField(String text, double x, double y, double w, double h)
          If height < 0, the height is automatically set to fit the font height.
TextField(String text, int x, int y)
           
TextField(String text, int x, int y, int w, int h)
          If height < 0, the height is automatically set to fit the font height.
 
Method Summary
protected  void drawSprite(CoreGraphics g)
          Draws the sprite.
 int getCaretPosition()
           
 int getMaxNumChars()
           
protected  int getNaturalHeight()
           
protected  int getNaturalWidth()
           
 String getText()
           
 boolean hasFocus()
           
 boolean isPasswordMode()
           
 void selectAll()
           
 void setCaretPosition(int position)
           
 void setCaretPosition(int position, boolean selectMode)
           
 void setFocus(boolean hasFocus)
           
 void setMaxNumChars(int maxNumChars)
           
 void setPasswordMode(boolean passwordMode)
           
 void setText(String text)
           
 void update(int elapsedTime)
          Updates all of this Sprite's properties.
 
Methods inherited from class pulpcore.sprite.Sprite
bindLocationTo, bindSizeTo, clearCursor, clearDirtyRect, contains, draw, getAnchor, getAnchorX, getAnchorY, getBlendMode, getCursor, getDirtyRect, getLocalX, getLocalY, getParent, getPixelLevelChecks, getRoot, getScene2D, getViewX, getViewX, getViewY, getViewY, intersects, isDirty, isEnabled, isEnabledAndVisible, isMouseDoubleClicked, isMouseDown, isMouseHover, isMouseOver, isMousePressed, isMouseReleased, isMouseTripleClicked, isMouseWheelRotated, isPick, isPickEnabledAndVisible, isTransparent, move, move, move, move, move, move, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, propertyChange, scale, scale, scale, scale, scale, scale, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, setAnchor, setBlendMode, setCursor, setDirty, setLocation, setLocation, setSize, setSize, translate, translate, updateDirtyRect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectionColor

public final Color selectionColor
The highlight color to use when text is selected. By default, the selection color is black.


caretColor

public final Color caretColor
The caret color. By default, the caret color is black.

Constructor Detail

TextField

public TextField(int x,
                 int y,
                 int w,
                 int h)
If height < 0, the height is automatically set to fit the font height.


TextField

public TextField(double x,
                 double y,
                 double w,
                 double h)
If height < 0, the height is automatically set to fit the font height.


TextField

public TextField(String text,
                 int x,
                 int y)

TextField

public TextField(String text,
                 int x,
                 int y,
                 int w,
                 int h)
If height < 0, the height is automatically set to fit the font height.


TextField

public TextField(String text,
                 double x,
                 double y)

TextField

public TextField(String text,
                 double x,
                 double y,
                 double w,
                 double h)
If height < 0, the height is automatically set to fit the font height.


TextField

public TextField(CoreFont font,
                 CoreFont selectionFont,
                 String text,
                 int x,
                 int y)

TextField

public TextField(CoreFont font,
                 CoreFont selectionFont,
                 String text,
                 int x,
                 int y,
                 int w,
                 int h)
If height < 0, the height is automatically set to fit the font height.


TextField

public TextField(CoreFont font,
                 CoreFont selectionFont,
                 String text,
                 double x,
                 double y)

TextField

public TextField(CoreFont font,
                 CoreFont selectionFont,
                 String text,
                 double x,
                 double y,
                 double w,
                 double h)
If height < 0, the height is automatically set to fit the font height.

Method Detail

getNaturalWidth

protected int getNaturalWidth()
Overrides:
getNaturalWidth in class Sprite

getNaturalHeight

protected int getNaturalHeight()
Overrides:
getNaturalHeight in class Sprite

isPasswordMode

public boolean isPasswordMode()

setPasswordMode

public void setPasswordMode(boolean passwordMode)

getText

public String getText()

setText

public void setText(String text)

setMaxNumChars

public void setMaxNumChars(int maxNumChars)

getMaxNumChars

public int getMaxNumChars()

hasFocus

public boolean hasFocus()

setFocus

public void setFocus(boolean hasFocus)

setCaretPosition

public void setCaretPosition(int position)

setCaretPosition

public void setCaretPosition(int position,
                             boolean selectMode)

getCaretPosition

public int getCaretPosition()

update

public void update(int elapsedTime)
Description copied from class: Sprite
Updates all of this Sprite's properties. Subclasses that override this method should call super.update().

Overrides:
update in class Sprite

selectAll

public void selectAll()

drawSprite

protected void drawSprite(CoreGraphics g)
Description copied from class: Sprite
Draws the sprite. The graphic context's alpha is set to this sprite, and it's translation is offset by this sprite's location. This method is not called if the sprite is not visible or it's alpha is less than or equal to zero.

Specified by:
drawSprite in class Sprite

PulpCore

Copyright © 2007-2008 Interactive Pulp, LLC.