You are reading 12.8.0. See this page in 13.4.1.
Titanium.UI.TextField
Extends Titanium.UI.ViewTitanium.Proxy
A single line text field.
| Android | iOS |
|---|---|
![]() |
![]() |
Use the Titanium.UI.createTextField method or <TextField> Alloy element to create a text field.
click event in iOS
In iOS 11+, click event in text field is not fired due to changes from apple.
Use touchstart event instead of click event.
Examples
Basic Text Field
Create a simple text field with green text color.
var win = Ti.UI.createWindow();
var textField = Ti.UI.createTextField({
backgroundColor: '#fafafa',
color: 'green',
width: 250,
height: 40
});
win.add(textField);
win.open();
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.Toolbar> for more information.
This code excerpt creates a text field with a toolbar:
var win = Ti.UI.createWindow();
var send = Ti.UI.createButton({
title: 'Send',
style: Ti.UI.iOS.SystemButtonStyle.DONE,
});
var camera = Ti.UI.createButton({
systemButton: Ti.UI.iOS.SystemButton.CAMERA,
});
var cancel = Ti.UI.createButton({
systemButton: Ti.UI.iOS.SystemButton.CANCEL
});
var flexSpace = Ti.UI.createButton({
systemButton: Ti.UI.iOS.SystemButton.FLEXIBLE_SPACE
});
var textfield = Ti.UI.createTextField({
borderStyle: Ti.UI.INPUT_BORDERSTYLE_BEZEL,
hintText: 'Focus to see keyboard with toolbar',
keyboardToolbar : [cancel, flexSpace, camera, flexSpace, send],
keyboardToolbarColor: '#999',
keyboardToolbarHeight: 40,
top: 10,
width: 300,
height: 35
});
win.add(textField);
win.open();
Alloy XML Markup
Previous basic text field with green text color example using Alloy.
Alternatively, define the properties using the TSS file.
<Alloy>
<Window id="win" backgroundColor="white">
<TextField class="myTextField" color="green" width="250" height="45" />
</Window>
</Alloy>
Alloy Custom Keyboard Toolbar (iOS)
Previous custom keyboard toolbar example as an Alloy view. Use the <KeyboardToolbar> XML
element to set the keyboardToolbar property.
You can also declare the leftButton and rightButton properties in XML markup as the
<LeftButton> and <RightButton> XML elements.
<Alloy>
<Window fullscreen="true" backgroundColor="white">
<TextField
platform="ios"
borderStyle="Ti.UI.INPUT_BORDERSTYLE_BEZEL"
keyboardToolbarColor="#999"
keyboardToolbarHeight="40"
top="10"
height="35"
width="300"
value="Focus to see keyboard with toolbar">
<!-- Sets the keyboardToolbar property -->
<KeyboardToolbar>
<Toolbar>
<Items>
<Button systemButton="CANCEL" />
<FlexSpace/>
<Button systemButton="CAMERA" />
<FlexSpace/>
<Button style="DONE">Send</Button>
</Items>
</Toolbar>
</KeyboardToolbar>
</TextField>
</Window>
</Alloy>
Properties 115
Inherited from Titanium.UI.View
Boolean value to remove the long press notification for the device's accessibility service.
Default: true
Inherited from Titanium.UI.View
Whether the view should be "hidden" from (i.e., ignored by) the accessibility service.
Default: false
Inherited from Titanium.UI.View
Briefly describes what performing an action (such as a click) on the view will do.
Default: null
Inherited from Titanium.UI.View
A succint label identifying the view for the device's accessibility service.
Inherited from Titanium.UI.View
A string describing the value (if any) of the view for the device's accessibility service.
Inherited from Titanium.UI.View
Coordinate of the view about which to pivot an animation.
Inherited from Titanium.UI.View
Current position of the view during an animation.
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
Hint text attributed string.
The attributed hint text by the textField. If set, avoid setting common attributes
in textField, such as hintText, color and font, as unexpected behaviors may result.
This has no effect when used with hintType Ti.UI.HINT_TYPE_ANIMATED.
Prior to Release 3.6.0, assign this property an object from the <Titanium.UI.iOS.AttributedString> class.
Since Appcelerator CLI 4.1.0 (Alloy 1.7.0), for Alloy, you can use an <AttributedHintText>
element inside a <TextField> element and set the text property as node text:
<Alloy>
<Window>
<TextField>
<AttributedHintText>
Alloy is great!
</AttributedHintText>
</TextField>
</Window>
</Alloy>
Then set attributes in the TSS file:
"AttributedString" : {
attributes: [
{
type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
value: 'red',
range: [0, 5]
},
{
type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,
value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
range: [9, 5]
}
]
}
TextField attributed string.
The underlying attributed string drawn by the textField. If set, avoid setting common attributes
in TextField, such as value, color and font, as unexpected behaviors may result.
For Alloy, you can use an <AttributedString> element inside a <TextField> element and set
the text property as node text:
<Alloy>
<Window>
<TextField>
<AttributedString>
Alloy is great!
</AttributedString>
</TextField>
</Window>
</Alloy>
Then set attributes in the TSS file:
"AttributedString" : {
attributes: [
{
type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
value: 'red',
range: [0, 5]
},
{
type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,
value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
range: [9, 5]
}
]
}
autocapitalization
NumberDetermines how text is capitalized during typing.
Default: <Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE>
autocorrect
BooleanDetermines whether to automatically correct text entered into this text field.
Set to true to enable automatic spelling correction. On iOS 9+, this can be used to disable QuickType suggestions.
If this property is not explicitly defined, it behaves as though it were set to true.
On iOS, the returned default value is false, and on Android, the returned
default value is undefined, but all behave as if the value is true.
Sets the autofill type for the text field.
This sets the hint or content type to aid the autofill feature of iOS and Android to function.
Accepts 32 constants
- AUTOFILL_TYPE_ADDRESS
- AUTOFILL_TYPE_ADDRESS_CITY
- AUTOFILL_TYPE_ADDRESS_CITY_STATE
- AUTOFILL_TYPE_ADDRESS_LINE1
- AUTOFILL_TYPE_ADDRESS_LINE2
- AUTOFILL_TYPE_ADDRESS_STATE
- AUTOFILL_TYPE_CARD_EXPIRATION_DATE
- AUTOFILL_TYPE_CARD_EXPIRATION_DAY
- AUTOFILL_TYPE_CARD_EXPIRATION_MONTH
- AUTOFILL_TYPE_CARD_EXPIRATION_YEAR
- AUTOFILL_TYPE_CARD_NUMBER
- AUTOFILL_TYPE_CARD_SECURITY_CODE
- AUTOFILL_TYPE_COUNTRY_NAME
- AUTOFILL_TYPE_EMAIL
- AUTOFILL_TYPE_FAMILY_NAME
- AUTOFILL_TYPE_GIVEN_NAME
- AUTOFILL_TYPE_JOB_TITLE
- AUTOFILL_TYPE_LOCATION
- AUTOFILL_TYPE_MIDDLE_NAME
- AUTOFILL_TYPE_NAME
- AUTOFILL_TYPE_NAME_PREFIX
- AUTOFILL_TYPE_NAME_SUFFIX
- AUTOFILL_TYPE_NEW_PASSWORD
- AUTOFILL_TYPE_NICKNAME
- AUTOFILL_TYPE_ONE_TIME_CODE
- AUTOFILL_TYPE_ORGANIZATION_NAME
- AUTOFILL_TYPE_PASSWORD
- AUTOFILL_TYPE_PHONE
- AUTOFILL_TYPE_POSTAL_CODE
- AUTOFILL_TYPE_SUBLOCALITY
- AUTOFILL_TYPE_URL
- AUTOFILL_TYPE_USERNAME
Default: undefined
Automatically convert text to clickable links.
Multiple autolink values can be combined with a bitwise OR. For example:
textField.autoLink = Ti.UI.AUTOLINK_MAP_ADDRESSES | Ti.UI.AUTOLINK_PHONE_NUMBERS;
The Android-specific LINKIFY legacy constants are defined in Titanium.UI.Android.
Accepts 12 constants
Default: undefined
backgroundColor
String | Titanium.UI.ColorInherited from Titanium.UI.View
Background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Disabled background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Disabled background image for the view, specified as a local file path or URL.
Inherited from Titanium.UI.View
Focused background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Focused background image for the view, specified as a local file path or URL.
Inherited from Titanium.UI.View
A background gradient for the view.
Linear and Radial Gradients
The following code excerpt creates two views, one with a linear gradient and one with a radial gradient.
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
layout: 'vertical'
});
var radialGradient = Ti.UI.createView({
top: 10,
width: 100,
height: 100,
backgroundGradient: {
type: 'radial',
startPoint: { x: 50, y: 50 },
endPoint: { x: 50, y: 50 },
colors: [ 'red', 'blue'],
startRadius: 50,
endRadius: 0,
backfillStart: true
}
});
var linearGradient = Ti.UI.createView({
top: 10,
width: 100,
height: 100,
backgroundGradient: {
type: 'linear',
startPoint: { x: '0%', y: '50%' },
endPoint: { x: '100%', y: '50%' },
colors: [ { color: 'red', offset: 0.0}, { color: 'blue', offset: 0.25 }, { color: 'red', offset: 1.0 } ],
}
});
win1.add(radialGradient);
win1.add(linearGradient);
win1.open();
backgroundImage
StringInherited from Titanium.UI.View
Background image for the view, specified as a local file path or URL.
Inherited from Titanium.UI.View
Size of the left end cap.
Default: 0
backgroundRepeat
BooleanInherited from Titanium.UI.View
Determines whether to tile a background across a view.
Default: false
Inherited from Titanium.UI.View
Selected background color of the view, as a color name or hex triplet.
Inherited from Titanium.UI.View
Selected background image url for the view, specified as a local file path or URL.
Inherited from Titanium.UI.View
Size of the top end cap.
Default: 0
borderColor
String | Titanium.UI.ColorInherited from Titanium.UI.View
Border color of the view, as a color name or hex triplet.
borderRadius
Number | String | Array<Number> | Array<String>Inherited from Titanium.UI.View
Radius for the rounded corners of the view's border.
Default: 0
Border style for the field.
On Android, this is a creation-only property and cannot be changed dynamically.
Default: <Titanium.UI.INPUT_BORDERSTYLE_NONE> (on iOS),
<Titanium.UI.INPUT_BORDERSTYLE_FILLED> (on Android)
borderWidth
NumberInherited from Titanium.UI.View
Border width of the view.
Default: 0
bottom
Number | StringInherited from Titanium.UI.View
View's bottom position, in platform-specific units.
Inherited from Titanium.Proxy
Indicates if the proxy will bubble an event to its parent.
Default: true
Inherited from Titanium.UI.View
View's center position, in the parent view's coordinates.
Determines when the clear button is displayed.
Default: Titanium.UI.INPUT_BUTTONMODE_NEVER
clearOnEdit
BooleanDetermines whether the value of this text field should be cleared when it is focused.
Default: false
Inherited from Titanium.UI.View
View's clipping behavior.
color
String | Titanium.UI.ColorColor of the text in this text field, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
editable
BooleanDetermines whether this field can be edited.
Default: true
Inherited from Titanium.UI.View
Base elevation of the view relative to its parent in pixels.
Determines whether an ellipsis (...) should be used to indicate truncated text.
Default: false
Determines if user can copy or cut text from the text field.
When set false, the "copy" and "cut" options will not appear in the context menu.
The Command+C and Command+X keyboard shortcuts will be ignored as well.
If Titanium.UI.TextField.passwordMask is set true, then copy support is always disabled,
even if you set this property true.
Default: true
enableReturnKey
BooleanDetermines whether the return key is enabled automatically when there is text in this text field.
If true, the return key is disabled when this text field is empty, and
automatically enabled as soon as the user types any text in the field.
On Android, if true, return event will not fire. Clicking on the return key will do nothing, but
the key itself won't be disabled.
Default: false
Inherited from Titanium.UI.View
Discards touch related events if another app's system overlay covers the view.
Default: false
Inherited from Titanium.UI.View
Whether view should be focusable while navigating with the trackball.
Default: false
Determines whether this TextField has focus.
Default: false
Font to use for text.
Leave some space above the keyboard in landscape mode or not.
Switch between a fullscreen keyboard in landscape mode (default) or a non-fullscreen keyboard which will leave some space to display UI elements.
Default: true
height
Number | StringInherited from Titanium.UI.View
View height, in platform-specific units.
hintText
StringHint text to display when the field is empty.
Hint text is hidden when the user enters text into this text field.
Use the backslash and letter n line feed character combination, ie \n, to force a new
line.
Use unicode characters, such as those included in (but not limited to) the Unicode List of Useful Symbols section of wikipedia, to insert special characters and symbols.
Default: No hint text.
Hint text color to display when the field is empty.
Sets the color of the Titanium.UI.TextField.hintText. Please not that this can be overriden by the Titanium.UI.TextField.attributedHintText which provides an advanced configuration to style hint texts.
This has no effect when used with hintType Ti.UI.HINT_TYPE_ANIMATED. Instead a theme must be
used that defines the android:textColorHint attribute.
Android Note: The hint text color in Android is determined by the theme of the application. By default, a Titanium app uses a Dark theme. When you create the background to be white, the hint text color would also be white, hence not visible to the user. To change this, you can edit the tiapp.xml file with another theme. Example as follows:
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<application android:theme="@style/Theme.MaterialComponents.Light.Bridge"/>
</manifest>
</android>
Another way to change the hint text color is to use this property and specify a color.
Default: The platform's default hint text color.
Key identifying a string from the locale file to use for the hintText property.
Only one of hintText or hinttextid should be specified.
Hint type to display on the text field.
Setting this to Titanium.UI.HINT_TYPE_ANIMATED will use the animated TextInputLayout on Android.
Default: <Titanium.UI.HINT_TYPE_STATIC>
Inherited from Titanium.UI.View
Adds a horizontal parallax effect to the view
Inherited from Titanium.UI.View
Determines whether the layout has wrapping behavior.
Default: true
id
StringInherited from Titanium.UI.View
View's identifier.
Input type to accept in the text field. Also influences the Keyboard type to display.
When asking for a specific kind of user input, such as a phone number or email address, you should always specify the input type that is accepted. This overrides any changes to the keyboard done by the property Titanium.UI.TextField.keyboardType.
Default: Empty array. If not defined, default is Keyboard type specified by <Titanium.UI.TextField.keyboardType>.
Inherited from Titanium.UI.View
Determines whether to keep the device screen on.
Default: false
Determines the appearance of the keyboard displayed when this field is focused.
Default: <Titanium.UI.KEYBOARD_APPEARANCE_DEFAULT>
Array of toolbar button objects or a toolbar to be used when the keyboard is displayed.
In Alloy, you can use a <KeyboardToolbar> element inside a <TextField> element to create
a KeyboardToolbar.
<Alloy>
<TextField id="textfield" platform="ios" hintText="Tap here...">
<!-- Nested properties -->
<KeyboardToolbar >
<Toolbar >
<Items >
<Button>button 1</Button>
<FlexSpace />
<Button>button 2</Button>
</Items>
</Toolbar>
</KeyboardToolbar>
</TextField>
</Alloy>
Color of the keyboard toolbar if keyboardToolbar is an array, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
Height of the keyboard toolbar if keyboardToolbar is an array.
keyboardType
NumberKeyboard type to display when this text field is focused.
When asking for a specific kind of user input, such as a phone number or email address, you should always specify the appropriate keyboard type.
Accepts 11 constants
Default: <Titanium.UI.KEYBOARD_TYPE_DEFAULT>
layout
StringInherited from Titanium.UI.View
Specifies how the view positions its children. One of: 'composite', 'vertical', or 'horizontal'.
left
Number | StringInherited from Titanium.UI.View
View's left position, in platform-specific units.
Left button view to display in the TextField.
Set the width and height properties of the button or else it does not display in the
text field.
Using an object other than a Button may have unpredictable results.
In Alloy you can use a <LeftButton> element inside the <TextField> element.
<Alloy>
<Window>
<!-- iOS TextField properties -->
<TextField id="textfield" platform="ios">
<LeftButton>
<Button onClick="sayHi">Say Hi</Button>
</LeftButton>
<RightButton>
<Button onClick="doAlert">Do Alert</Button>
</RightButton>
</TextField>
</Window>
</Alloy>
Determines when to display the left button view.
Default: <Titanium.UI.INPUT_BUTTONMODE_NEVER>
Padding between the left button and the edge of the field.
Inherited from Titanium.Proxy
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
Maximum length of text field input.
Any attempt to input text beyond this length (including pasting a string larger than maxLength) will not edit the field's contents. A value of -1 indicates unlimited length.
Default: -1
Minimum size of the font when the font is sized based on the contents. Enables font scaling to fit.
opacity
NumberInherited from Titanium.UI.View
Opacity of this view, from 0.0 (transparent) to 1.0 (opaque). Defaults to 1.0 (opaque).
Inherited from Titanium.UI.View
When on, animate call overrides current animation if applicable.
Sets the padding of this text field.
passwordMask
BooleanObscure the input text from the user.
Set to true to hide entered characters.
Note: on iOS, passwordMask must be specified when this text field is created.
Default: false
Set password rules that should be used for this text field.
This property is used to communicate requirements for passwords for your service
to ensure iOS can generate compatible passwords for users. It only works when Titanium.UI.TextField.passwordMask
is true. You do not need to use this property if the passwords that iOS generates are already
compatible with your service. You can learn more about the purpose of and syntax for these rules
on the Password Rules documentation guide.
Inherited from Titanium.UI.View
The preview context used in the 3D-Touch feature "Peek and Pop".
Inherited from Titanium.UI.View
Background color of the wrapper view when this view is used as either Titanium.UI.ListView.pullView or Titanium.UI.TableView.headerPullView.
Defaults to undefined. Results in a light grey background color on the wrapper view.
Inherited from Titanium.UI.View
The bounding box of the view relative to its parent, in system units.
returnKeyType
NumberSpecifies the text to display on the keyboard Return key when this field is focused.
Accepts 12 constants
Default: <Titanium.UI.RETURNKEY_DEFAULT>
right
Number | StringInherited from Titanium.UI.View
View's right position, in platform-specific units.
Right button view.
Set the width and height properties of the button or else it does not display in the
text field.
Using an object other than a Button may have unpredictable results.
In Alloy you can use a <RightButton> element inside the <TextField> element.
<Alloy>
<Window>
<!-- iOS TextField properties -->
<TextField id="textfield" platform="ios">
<LeftButton>
<Button onClick="sayHi">Say Hi</Button>
</LeftButton>
<RightButton>
<Button onClick="doAlert">Do Alert</Button>
</RightButton>
</TextField>
</Window>
</Alloy>
The sayHi and doAlert methods are defined in the Alloy controller.
Determines when to display the right button view.
Default: Titanium.UI.INPUT_BUTTONMODE_NEVER
Padding between the right button and the edge of the field.
Inherited from Titanium.UI.View
Clockwise 2D rotation of the view in degrees.
Inherited from Titanium.UI.View
Clockwise rotation of the view in degrees (x-axis).
Inherited from Titanium.UI.View
Clockwise rotation of the view in degrees (y-axis).
Inherited from Titanium.UI.View
Scaling of the view in x-axis in pixels.
Inherited from Titanium.UI.View
Scaling of the view in y-axis in pixels.
Returns the currently selected text of the text field.
This property is useful to track the current cursor position of the text field. On iOS this property can only be used when the text field has focus. Accessing this property when text field does not have focus will return an undefined value.
This method will return null on android and undefined on iOS if the view has not yet been attached to the window.
Determinates if the undo and redo buttons on the left side of the keyboard should be displayed or not. Only valid on iOS9 and above.
Default: true
Inherited from Titanium.UI.View
The size of the view in system units.
Inherited from Titanium.UI.View
Determines keyboard behavior when this view is focused. Defaults to Titanium.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS.
Determines whether the return key should be suppressed during entry.
textAlign
String | NumberText alignment within this text field.
This has no effect on hintText when hintType is Ti.UI.HINT_TYPE_ANIMATED.
Default: <Titanium.UI.TEXT_ALIGNMENT_LEFT>
Inherited from Titanium.UI.View
The view's tintColor
Default: null
Inherited from Titanium.UI.View
The default text to display in the control's tooltip.
top
Number | StringInherited from Titanium.UI.View
The view's top position.
touchEnabled
BooleanInherited from Titanium.UI.View
Determines whether view should receive touch events.
Default: true
Inherited from Titanium.UI.View
A material design visual construct that provides an instantaneous visual confirmation of touch point.
Default: false
Inherited from Titanium.UI.View
Optional touch feedback ripple color. This has no effect unless touchFeedback is true.
Inherited from Titanium.UI.View
Transformation matrix to apply to the view.
Default: Identity matrix
Inherited from Titanium.UI.View
A name to identify this view in activity transition.
Inherited from Titanium.UI.View
Horizontal location of the view relative to its left position in pixels.
Inherited from Titanium.UI.View
Vertical location of the view relative to its top position in pixels.
Inherited from Titanium.UI.View
Depth of the view relative to its elevation in pixels.
value
StringValue of this text field, which may be set programmatically and modified by the user.
Use the backslash and letter n line feed character combination, ie \n, to force a new
line.
Use unicode characters, such as those included in (but not limited to) the Unicode List of Useful Symbols section of wikipedia, to insert special characters and symbols.
verticalAlign
Number | StringVertical alignment within this text field.
Default: <Titanium.UI.TEXT_VERTICAL_ALIGNMENT_CENTER>
Inherited from Titanium.UI.View
Adds a vertical parallax effect to the view
viewShadowColor
String | Titanium.UI.Colorsince Android 11.1.0, iPhone 3.3.0, iPad 3.3.0, macOS 9.2.0Inherited from Titanium.UI.View
Determines the color of the shadow.
Inherited from Titanium.UI.View
Determines the offset for the shadow of the view.
Inherited from Titanium.UI.View
Determines the blur radius used to create the shadow.
visible
BooleanInherited from Titanium.UI.View
Determines whether the view is visible.
Default: true
width
Number | StringInherited from Titanium.UI.View
View's width, in platform-specific units.
zIndex
NumberInherited from Titanium.UI.View
Z-index stack order position, relative to other sibling views.
Methods 17
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
Inherited from Titanium.UI.View
Animates this view.
| Parameters | Type | Description |
|---|---|---|
| animation | Titanium.UI.Animation | Dictionary<Titanium.UI.Animation> | Either a dictionary of animation properties or an Animation object. |
| callback? | Callback<Object> | Function to be invoked upon completion of the animation. |
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
Forces the field to lose focus.
Inherited from Titanium.UI.View
Removes all previously added motion effects.
convertPointToView
since Android 1.8, iPhone 1.8, iPad 1.8, macOS 9.2.0Inherited from Titanium.UI.View
Translates a point from this view's coordinate system to another view's coordinate system.
| Parameters | Type | Description |
|---|---|---|
| point | Point | A point in this view's coordinate system. If this argument is missing an |
| destinationView | Titanium.UI.View | View that specifies the destination coordinate system to convert to. If this argument is not a view, an exception will be raised. |
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| event? | Dictionary | A dictionary of keys and values to add to the Titanium.Event object sent to the listeners. |
Forces the field to gain focus.
getViewById
since 6.1.0Inherited from Titanium.UI.View
Returns the matching view of a given view ID.
| Parameters | Type | Description |
|---|---|---|
| id | String | The ID of the view that should be returned. Use the |
hasText
since 2.1.0Returns true if this text field contains text.
True if this text field contains text.
Inherited from Titanium.UI.View
Hides this view.
| Parameters | Type | Description |
|---|---|---|
| options? | AnimatedOptions | Animation options for Android only. Since SDK 5.1.0 and used only on Android 5.0+ Determines whether to enable a circular reveal animation.
Note that the default here is equivalent to passing in |
insertAt
since 3.3.0Inherited from Titanium.UI.View
Inserts a view at the specified position in the children array.
| Parameters | Type | Description |
|---|---|---|
| params | ViewPositionOptions | Pass an object that specifies the view to insert and optionally at which position (defaults to end) 2 fields
|
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
setSelection
since 3.0.0Selects the text in range (start, end).
Selects the text in range (start, end). If start equals end, no text will be selected, and the cursor will move to the start position. End is not inclusive, meaning setSelection(0,0) will not select the first character, but will move the cursor to the position before the first character.
On iOS, soft keyboard would show when text is selected.
| Parameters | Type | Description |
|---|---|---|
| start | Number | Start index for selection. Value ranges from 0 to the text's length. |
| end | Number | End index for selection, not inclusive. Value ranges from 0 to the text's length. |
Inherited from Titanium.UI.View
Makes this view visible.
| Parameters | Type | Description |
|---|---|---|
| options? | AnimatedOptions | Animation options for Android only. Since SDK 5.1.0 and only used on Android 5.0+ Determines whether to enable a circular reveal animation.
Note that the default here is equivalent to passing in |
Inherited from Titanium.UI.View
Stops a running animation.
Inherited from Titanium.UI.View
Returns an image of the rendered view, as a Blob.
| Parameters | Type | Description |
|---|---|---|
| callback? | Callback<Titanium.Blob> | Function to be invoked upon completion. If non-null, this method will be performed asynchronously. If null, it will be performed immediately. |
| honorScaleFactor? | Boolean | Determines whether the image is scaled based on scale factor of main screen. (iOS only) When set to true, image is scale factor is honored. When set to false, the image in the blob has the same dimensions for retina and non-retina devices. |
Events 21
Fired when the field loses focus.
| Event properties | Type | Description |
|---|---|---|
| value | String | Value of the field. |
Fired when the field value changes.
| Event properties | Type | Description |
|---|---|---|
| value | String | New value of the field. |
Inherited from Titanium.UI.View
Fired when the device detects a click against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when the device detects a double click against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when the device detects a double tap against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Fired when the field is empty and you press backspace key again.
| Event properties | Type | Description |
|---|---|---|
| keyCode | Number | Key code of the key. |
Fired when the field gains focus.
| Event properties | Type | Description |
|---|---|---|
| value | String | Value of the field. |
keypressed
since Android 3.1.0, iPhone 5.4.0, iPad 5.4.0, macOS 9.2.0Inherited from Titanium.UI.View
Fired when a hardware key is pressed in the view.
| Event properties | Type | Description |
|---|---|---|
| keyCode | Number | The code for the physical key that was pressed. For more details, see KeyEvent. This API is experimental and subject to change. |
longclick
AndroidInherited from Titanium.UI.View
Fired when the device detects a long click.
Inherited from Titanium.UI.View
Fired when the device detects a long press.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
pinch
since 1.8.0Inherited from Titanium.UI.View
Fired when the device detects a pinch gesture.
| Event properties | Type | Description |
|---|---|---|
| scale | Number | The scale factor relative to the points of the two touches in screen coordinates. |
| velocity | Number | The velocity of the pinch in scale factor per second. |
| time | Number | The event time of the current event being processed. |
| timeDelta | Number | The time difference in milliseconds between the previous accepted scaling event and the current scaling event. |
| currentSpan | Number | The average distance between each of the pointers forming the gesture in progress through the focal point. |
| currentSpanX | Number | The average X distance between each of the pointers forming the gesture in progress through the focal point. |
| currentSpanY | Number | The average Y distance between each of the pointers forming the gesture in progress through the focal point. |
| previousSpan | Number | The previous average distance between each of the pointers forming the gesture in progress through the focal point. |
| previousSpanX | Number | The previous average X distance between each of the pointers forming the gesture in progress through the focal point. |
| previousSpanY | Number | The previous average Y distance between each of the pointers forming the gesture in progress through the focal point. |
| focusX | Number | The X coordinate of the current gesture's focal point. |
| focusY | Number | The Y coordinate of the current gesture's focal point. |
| inProgress | Boolean | Returns |
postlayout
since 2.0.0Inherited from Titanium.UI.View
Fired when a layout cycle is finished.
Fired when the return key is pressed on the keyboard.
| Event properties | Type | Description |
|---|---|---|
| value | String | Value of this text area. |
rotate
since 12.7.0Inherited from Titanium.UI.View
Fired when the device detects a two finger rotation.
| Event properties | Type | Description |
|---|---|---|
| rotate | Number | Rotation in degrees. |
Inherited from Titanium.UI.View
Fired when the device detects a single tap against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when the device detects a swipe gesture against the view.
| Event properties | Type | Description |
|---|---|---|
| direction | String | Direction of the swipe--either 'left', 'right', 'up', or 'down'. |
| x | Number | X coordinate of the event's endpoint from the |
| y | Number | Y coordinate of the event's endpoint from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when a touch event is interrupted by the device.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| force | Number | The current force value of the touch event. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later and on some Android devices. |
| size | Number | The current size of the touch area. Note: This property is only available on some Android devices. |
| maximumPossibleForce | Number | Maximum possible value of the force property. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| altitudeAngle | Number | A value which indicates the stylus angle on the screen. If the stylus is perpendicular to the screen or no stylus is being used, the value will be Pi/2. If the stylus is parallel to the screen, the value will be 0. Note: This property is only available for iOS devices that support 3D-Touch and are 9.1 or later. |
| timestamp | Number | The time (in seconds) when the touch was used in correlation with the system start up. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| azimuthUnitVectorInViewX | Number | The x value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| azimuthUnitVectorInViewY | Number | The y value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired when a touch event is completed.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| force | Number | The current force value of the touch event. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later and on some Android devices. |
| size | Number | The current size of the touch area. Note: This property is only available on some Android devices. |
| maximumPossibleForce | Number | Maximum possible value of the force property. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| altitudeAngle | Number | A value which indicates the stylus angle on the screen. If the stylus is perpendicular to the screen or no stylus is being used, the value will be Pi/2. If the stylus is parallel to the screen, the value will be 0. Note: This property is only available for iOS devices that support 3D-Touch and are 9.1 or later. |
| timestamp | Number | The time (in seconds) when the touch was used in correlation with the system start up. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| azimuthUnitVectorInViewX | Number | The x value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| azimuthUnitVectorInViewY | Number | The y value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Penciland are 9.1 or later. |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired as soon as the device detects movement of a touch.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| force | Number | The current force value of the touch event. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later and on some Android devices. |
| size | Number | The current size of the touch area. Note: This property is only available on some Android devices. |
| maximumPossibleForce | Number | Maximum possible value of the force property. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| altitudeAngle | Number | A value which indicates the stylus angle on the screen. If the stylus is perpendicular to the screen or no stylus is being used, the value will be Pi/2. If the stylus is parallel to the screen, the value will be 0. Note: This property is only available for iOS devices that support 3D-Touch and are 9.1 or later. |
| timestamp | Number | The time (in seconds) when the touch was used in correlation with the system start up. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| azimuthUnitVectorInViewX | Number | The x value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| azimuthUnitVectorInViewY | Number | The y value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
Inherited from Titanium.UI.View
Fired as soon as the device detects a touch gesture.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| force | Number | The current force value of the touch event. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later and on some Android devices. |
| size | Number | The current size of the touch area. Note: This property is only available on some Android devices. |
| maximumPossibleForce | Number | Maximum possible value of the force property. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| altitudeAngle | Number | A value which indicates the stylus angle on the screen. If the stylus is perpendicular to the screen or no stylus is being used, the value will be Pi/2. If the stylus is parallel to the screen, the value will be 0. Note: This property is only available for iOS devices that support 3D-Touch and are 9.1 or later. |
| timestamp | Number | The time (in seconds) when the touch was used in correlation with the system start up. Note: This property is only available for iOS devices that support 3D-Touch and run 9.0 or later. |
| azimuthUnitVectorInViewX | Number | The x value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| azimuthUnitVectorInViewY | Number | The y value of the unit vector that points in the direction of the azimuth of the stylus. Note: This property is only available for iOS devices that support the Apple Pencil and are 9.1 or later. |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |
twofingertap
since 3.0.0Inherited from Titanium.UI.View
Fired when the device detects a two-finger tap against the view.
| Event properties | Type | Description |
|---|---|---|
| x | Number | X coordinate of the event from the |
| y | Number | Y coordinate of the event from the |
| obscured | Boolean | Returns This is a security feature to protect an app from "tapjacking", where a malicious app can use a system overlay to intercept touch events in your app or to trick the end-user to tap on UI in your app intended for the overlay. |

