Titanium.UI.TextField

Object of Titanium.UI.
Platform Since
Android 0.8
iPhone 0.8
iPad 0.8
Mobile Web 1.8

Summary

A single line text field.

Description

Use the Titanium.UI.createTextField method to create a text field.

Code Examples

Basic Text Field with rounded border

Create a simple text field with a round border style.

var tf1 = Titanium.UI.createTextField({
    color:'#336699',
    height:35,
    top:10,
    left:10,
    width:250,
    borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});

Custom Keyboard Toolbar (iOS)

On iOS, a configurable toolbar can be displayed above the virtual keyboard. Toolbars can be used with both text areas and text fields. See Titanium.UI.iOS.Toolbar for more information.

This code excerpt creates a text field with a toolbar:

var send = Titanium.UI.createButton({
    title : 'Send',
    style : Titanium.UI.iPhone.SystemButtonStyle.DONE,
});
 
var camera = Titanium.UI.createButton({
    systemButton : Titanium.UI.iPhone.SystemButton.CAMERA,
});
 
var cancel = Titanium.UI.createButton({
    systemButton : Titanium.UI.iPhone.SystemButton.CANCEL
});
 
var flexSpace = Titanium.UI.createButton({
    systemButton : Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
});
 
var textfield = Titanium.UI.createTextField({
    hintText : 'Focus to see keyboard with toolbar',
    height : 35,
    width : 300,
    top : 10,
    borderStyle : Titanium.UI.INPUT_BORDERSTYLE_BEZEL,
    keyboardToolbar : [cancel, flexSpace, camera, flexSpace, send],
    keyboardToolbarColor : '#999',
    keyboardToolbarHeight : 40,
});

Methods

Name Summary
add

Adds a child to this view's hierarchy.

addEventListener

Adds the specified callback as an event listener for the named event.

animate

Animates this view.

blur

Forces the field to lose focus.

convertPointToView

Translates a point from this view's coordinate system to another view's coordinate system. (Android, iPhone, iPad only.)

fireEvent

Fires a synthesized event to any registered listeners.

focus

Forces the field to gain focus.

getAnchorPoint

Gets the value of the anchorPoint property. (iPhone, iPad only.)

getAnimatedCenterPoint

Gets the value of the animatedCenterPoint property. (Android, iPhone, iPad only.)

getAppearance

Gets the value of the appearance property. (iPhone, iPad only.)

getAutocapitalization

Gets the value of the autocapitalization property.

getBackgroundColor

Gets the value of the backgroundColor property.

getBackgroundDisabledColor

Gets the value of the backgroundDisabledColor property. (Android only.)

getBackgroundDisabledImage

Gets the value of the backgroundDisabledImage property. (Android only.)

getBackgroundFocusedColor

Gets the value of the backgroundFocusedColor property. (Android only.)

getBackgroundFocusedImage

Gets the value of the backgroundFocusedImage property. (Android only.)

getBackgroundGradient

Gets the value of the backgroundGradient property. (iPhone, iPad, Mobile Web only.)

getBackgroundImage

Gets the value of the backgroundImage property.

getBackgroundLeftCap

Gets the value of the backgroundLeftCap property. (iPhone, iPad only.)

getBackgroundSelectedColor

Gets the value of the backgroundSelectedColor property. (Android, Mobile Web only.)

getBackgroundSelectedImage

Gets the value of the backgroundSelectedImage property. (Android, Mobile Web only.)

getBackgroundTopCap

Gets the value of the backgroundTopCap property. (iPhone, iPad only.)

getBorderColor

Gets the value of the borderColor property.

getBorderRadius

Gets the value of the borderRadius property.

getBorderStyle

Gets the value of the borderStyle property.

getBorderWidth

Gets the value of the borderWidth property.

getBottom

Gets the value of the bottom property.

getCenter

Gets the value of the center property.

getClearButtonMode

Gets the value of the clearButtonMode property. (Android, iPhone, iPad only.)

getClearOnEdit

Gets the value of the clearOnEdit property.

getEditable

Gets the value of the editable property.

getEnabled

Gets the value of the enabled property.

getFocusable

Gets the value of the focusable property. (Android only.)

getHeight

Gets the value of the height property.

getHintText

Gets the value of the hintText property.

getKeepScreenOn

Gets the value of the keepScreenOn property. (Android only.)

getKeyboardToolbar

Gets the value of the keyboardToolbar property. (iPhone, iPad only.)

getKeyboardToolbarColor

Gets the value of the keyboardToolbarColor property. (iPhone, iPad only.)

getKeyboardToolbarHeight

Gets the value of the keyboardToolbarHeight property. (iPhone, iPad only.)

getKeyboardType

Gets the value of the keyboardType property. (Android, iPhone, iPad only.)

getLayout

Gets the value of the layout property.

getLeft

Gets the value of the left property.

getLeftButton

Gets the value of the leftButton property. (iPhone, iPad only.)

getLeftButtonMode

Gets the value of the leftButtonMode property. (iPhone, iPad only.)

getLeftButtonPadding

Gets the value of the leftButtonPadding property. (Android, iPhone, iPad only.)

getMaxLength

Gets the value of the maxLength property. (iPhone only.)

getMinimumFontSize

Gets the value of the minimumFontSize property. (iPhone, iPad only.)

getOpacity

Gets the value of the opacity property.

getPaddingLeft

Gets the value of the paddingLeft property.

getPaddingRight

Gets the value of the paddingRight property.

getPasswordMask

Gets the value of the passwordMask property.

getReturnKeyType

Gets the value of the returnKeyType property. (Android, iPhone, iPad only.)

getRight

Gets the value of the right property.

getRightButton

Gets the value of the rightButton property. (iPhone, iPad only.)

getRightButtonMode

Gets the value of the rightButtonMode property. (iPhone, iPad only.)

getRightButtonPadding

Gets the value of the rightButtonPadding property. (iPhone, iPad only.)

getSize

Gets the value of the size property.

getSoftKeyboardOnFocus

Gets the value of the softKeyboardOnFocus property. (Android only.)

getSuppressReturn

Gets the value of the suppressReturn property.

getTextAlign

Gets the value of the textAlign property.

getTop

Gets the value of the top property.

getTouchEnabled

Gets the value of the touchEnabled property.

getTransform

Gets the value of the transform property. (Android, iPhone, iPad only.)

getValue

Gets the value of the value property.

getVerticalAlign

Gets the value of the verticalAlign property.

getVisible

Gets the value of the visible property.

getWidth

Gets the value of the width property.

getZIndex

Gets the value of the zIndex property.

hasText

Returns true if the field contains text, false if it is empty.

hide

Hides this view.

remove

Removes a child view from this view's hierarchy.

removeEventListener

Removes the specified callback as an event listener for the named event.

setAnchorPoint

Sets the value of the anchorPoint property. (iPhone, iPad only.)

setAppearance

Sets the value of the appearance property. (iPhone, iPad only.)

setAutocapitalization

Sets the value of the autocapitalization property.

setBackgroundColor

Sets the value of the backgroundColor property.

setBackgroundDisabledColor

Sets the value of the backgroundDisabledColor property. (Android only.)

setBackgroundDisabledImage

Sets the value of the backgroundDisabledImage property. (Android only.)

setBackgroundFocusedColor

Sets the value of the backgroundFocusedColor property. (Android only.)

setBackgroundFocusedImage

Sets the value of the backgroundFocusedImage property. (Android only.)

setBackgroundGradient

Sets the value of the backgroundGradient property. (iPhone, iPad, Mobile Web only.)

setBackgroundImage

Sets the value of the backgroundImage property.

setBackgroundLeftCap

Sets the value of the backgroundLeftCap property. (iPhone, iPad only.)

setBackgroundSelectedColor

Sets the value of the backgroundSelectedColor property. (Android, Mobile Web only.)

setBackgroundSelectedImage

Sets the value of the backgroundSelectedImage property. (Android, Mobile Web only.)

setBackgroundTopCap

Sets the value of the backgroundTopCap property. (iPhone, iPad only.)

setBorderColor

Sets the value of the borderColor property.

setBorderRadius

Sets the value of the borderRadius property.

setBorderStyle

Sets the value of the borderStyle property.

setBorderWidth

Sets the value of the borderWidth property.

setBottom

Sets the value of the bottom property.

setCenter

Sets the value of the center property.

setClearButtonMode

Sets the value of the clearButtonMode property. (Android, iPhone, iPad only.)

setClearOnEdit

Sets the value of the clearOnEdit property.

setEditable

Sets the value of the editable property.

setEnabled

Sets the value of the enabled property.

setFocusable

Sets the value of the focusable property. (Android only.)

setHeight

Sets the value of the height property.

setHintText

Sets the value of the hintText property.

setKeepScreenOn

Sets the value of the keepScreenOn property. (Android only.)

setKeyboardToolbar

Sets the value of the keyboardToolbar property. (iPhone, iPad only.)

setKeyboardToolbarColor

Sets the value of the keyboardToolbarColor property. (iPhone, iPad only.)

setKeyboardToolbarHeight

Sets the value of the keyboardToolbarHeight property. (iPhone, iPad only.)

setKeyboardType

Sets the value of the keyboardType property. (Android, iPhone, iPad only.)

setLayout

Sets the value of the layout property.

setLeft

Sets the value of the left property.

setLeftButton

Sets the value of the leftButton property. (iPhone, iPad only.)

setLeftButtonMode

Sets the value of the leftButtonMode property. (iPhone, iPad only.)

setLeftButtonPadding

Sets the value of the leftButtonPadding property. (Android, iPhone, iPad only.)

setMaxLength

Sets the value of the maxLength property. (iPhone only.)

setMinimumFontSize

Sets the value of the minimumFontSize property. (iPhone, iPad only.)

setOpacity

Sets the value of the opacity property.

setPaddingLeft

Sets the value of the paddingLeft property.

setPaddingRight

Sets the value of the paddingRight property.

setPasswordMask

Sets the value of the passwordMask property.

setReturnKeyType

Sets the value of the returnKeyType property. (Android, iPhone, iPad only.)

setRight

Sets the value of the right property.

setRightButton

Sets the value of the rightButton property. (iPhone, iPad only.)

setRightButtonMode

Sets the value of the rightButtonMode property. (iPhone, iPad only.)

setRightButtonPadding

Sets the value of the rightButtonPadding property. (iPhone, iPad only.)

setSize

Sets the value of the size property.

setSoftKeyboardOnFocus

Sets the value of the softKeyboardOnFocus property. (Android only.)

setSuppressReturn

Sets the value of the suppressReturn property.

setTextAlign

Sets the value of the textAlign property.

setTop

Sets the value of the top property.

setTouchEnabled

Sets the value of the touchEnabled property.

setTransform

Sets the value of the transform property. (Android, iPhone, iPad only.)

setValue

Sets the value of the value property.

setVerticalAlign

Sets the value of the verticalAlign property.

setVisible

Sets the value of the visible property.

setWidth

Sets the value of the width property.

setZIndex

Sets the value of the zIndex property.

show

Makes this view visible.

toImage

Returns an image of the rendered view, as a Blob. (Android, iPhone, iPad only.)

Properties

Name Type Summary
anchorPoint Point

Anchor point where animation should occur, relative to the view's boundaries. (iPhone, iPad only.)

animatedCenterPoint Point

Current position of the view during an animation. (Android, iPhone, iPad only.) read-only

appearance Number

Determines the appearance of the keyboard displayed when this field is focused. (iPhone, iPad only.)

autocapitalization Number

Determines how text is capitalized during typing.

backgroundColor String

Background color of the view.

backgroundDisabledColor String

Disabled background color of the view. (Android only.)

backgroundDisabledImage String

Disabled background image for the view, specified as a local file path or URL. (Android only.)

backgroundFocusedColor String

Focused background color of the view. (Android only.)

backgroundFocusedImage String

Focused background image for the view, specified as a local file path or URL. (Android only.)

backgroundGradient Gradient

A background gradient for the view. (iPhone, iPad, Mobile Web only.)

backgroundImage String

Background image for the view, specified as a local file path or URL.

backgroundLeftCap Number

Size of the left end cap. (iPhone, iPad only.)

backgroundSelectedColor String

Selected background color of the view. (Android, Mobile Web only.)

backgroundSelectedImage String

Selected background image url for the view, specified as a local file path or URL. (Android, Mobile Web only.)

backgroundTopCap Number

Size of the top end cap. (iPhone, iPad only.)

borderColor String

Border color of the view.

borderRadius Number

Border radius of the view.

borderStyle Number

Border style for the field.

borderWidth Number

Border width of the view.

bottom Number or String

View's bottom position, in platform-specific units.

center Point

View's center position, in the parent view's coordinates.

clearButtonMode Number

When to display the clear button. (Android, iPhone, iPad only.)

clearOnEdit Boolean

Should the value of the field be cleared when the user starts editing?

editable Boolean

Is the field editable?

enabled Boolean

Is the field enabled?

focusable Boolean

Whether view should be focusable while navigating with the trackball. (Android only.)

height Number or String

View height, in platform-specific units.

hintText String

Hint text to display when the field is unfocused.

keepScreenOn Boolean

Whether to keep the device screen on. (Android only.)

keyboardToolbar Array<Object>

Array of toolbar button objects to be used when the keyboard is displayed. (iPhone, iPad only.)

keyboardToolbarColor String

Color of the keyboard toolbar. (iPhone, iPad only.)

keyboardToolbarHeight Number

Height of the keyboard toolbar. (iPhone, iPad only.)

keyboardType Number

Specifies the keyboard type to display when this field is focused, such as KEYBOARD_EMAIL or KEYBOARD_NUMBER_PAD. (Android, iPhone, iPad only.)

layout String

Specifies how the view positions its children. One of: 'absolute', 'vertical', or 'horizontal'.

left Number or String

View's left position, in platform-specific units.

leftButton Object

Left button view. Using an object other than a Button may have unpredictable results. (iPhone, iPad only.)

leftButtonMode Number

When to display the left button view. (iPhone, iPad only.)

leftButtonPadding Number

Padding between the left button and the edge of the field. (Android, iPhone, iPad only.)

maxLength Number

Maximum length of text field input. (iPhone only.)

minimumFontSize Number

Minimum size of the font when the font is sized based on the contents. Enables font scaling to fit. (iPhone, iPad only.)

opacity Number

Opacity of this view, from 0.0 (transparent) to 1.0 (opaque).

paddingLeft Number

Left padding of the text field.

paddingRight Number

Right padding of the text field.

passwordMask Boolean

Set to true to hide entered characters.

returnKeyType Number

Specifies the text to display on the keyboard Return key when this field is focused. (Android, iPhone, iPad only.)

right Number or String

View's right position, in platform-specific units.

rightButton Object

Right button view. (iPhone, iPad only.)

rightButtonMode Number

When to display the right button view. (iPhone, iPad only.)

rightButtonPadding Number

Padding between the right button and the edge of the field. (iPhone, iPad only.)

size Object

Size of the view as a dictionary of width and height properties.

softKeyboardOnFocus Number

Determines keyboard behavior when this view is focused. (Android only.)

suppressReturn Boolean

Should the return key should be suppressed during entry?

textAlign String or Number

Text alignment, specified using one of the Titanium.UI text alignment constants: TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER, or TEXT_ALIGNMENT_RIGHT.

top Number or String

The view's top position.

touchEnabled Boolean

Whether view should receive touch events.

transform Titanium.UI.2DMatrix or Titanium.UI.iOS.3DMatrix

Transformation matrix to apply to the view. (Android, iPhone, iPad only.)

value String

Value of the field.

verticalAlign Number or String

Vertical alignment for the text field, specified using one of the vertical alignment constants from Titanium.UI: TEXT_VERTICAL_ALIGNMENT_BOTTOM, TEXT_VERTICAL_ALIGNMENT_CENTER, or TEXT_VERTICAL_ALIGNMENT_TOP.

visible Boolean

Boolean value indicating whether the view is visible.

width Number or String

View's width, in platform-specific units.

zIndex Number

Z index position relative to other sibling views.

Events

Name Summary
blur

Fired when the field loses focus. (Android, iPhone, iPad only.)

change

Fired when the field value changes. (Android, iPhone, iPad only.)

click

Fired when the device detects a click against the view.

dblclick

Fired when the device detects a double click against the view.

doubletap

Fired when the device detects a double tap against the view. (Android, iPhone, iPad only.)

focus

Fired when the field gains focus. (Android, iPhone, iPad only.)

longclick

Fired when the device detects a long click. (Android only.)

longpress

Fired when the device detects a long press. (Android, iPhone, iPad only.)

pinch

Fired when the device detects a pinch gesture.

return

Fired when the return key is pressed on the keyboard. (Android, iPhone, iPad only.)

singletap

Fired when the device detects a single tap against the view.

swipe

Fired when the device detects a swipe gesture (left or right) against the view. (iPhone, iPad, Mobile Web only.)

touchcancel

Fired when a touch event is interrupted by the device.

touchend

Fired when a touch event is completed.

touchmove

Fired as soon as the device detects movement of a touch.

touchstart

Fired as soon as the device detects a touch gesture.

twofingertap

Fired when the device detects a two-finger tap against the view.