From 22ea66923f437fe91657f90b146404eb0d0e51ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Oghin=C4=83?= Date: Mon, 22 Jun 2015 13:06:11 -0100 Subject: [PATCH] [react_native] JS files from D2172754: support setting the cursor position in TextInput --- Libraries/Components/TextInput/TextInput.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index d2845e601..a69491254 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -44,6 +44,8 @@ var AndroidTextInputAttributes = { autoCapitalize: true, autoCorrect: true, autoFocus: true, + textAlign: true, + textAlignVertical: true, keyboardType: true, multiline: true, password: true, @@ -124,6 +126,19 @@ var TextInput = React.createClass({ * If true, focuses the input on componentDidMount. Default value is false. */ autoFocus: PropTypes.bool, + /** + * Set the position of the cursor from where editing will begin. + */ + textAlign: PropTypes.oneOf([ + 'start', + 'center', + 'end', + ]), + textAlignVertical: PropTypes.oneOf([ + 'top', + 'center', + 'bottom', + ]), /** * If false, text is not editable. Default value is true. */ @@ -466,6 +481,10 @@ var TextInput = React.createClass({ _renderAndroid: function() { var autoCapitalize = RCTUIManager.UIText.AutocapitalizationType[this.props.autoCapitalize]; + var textAlign = + RCTUIManager.AndroidTextInput.Constants.TextAlign[this.props.textAlign]; + var textAlignVertical = + RCTUIManager.AndroidTextInput.Constants.TextAlignVertical[this.props.textAlignVertical]; var children = this.props.children; var childCount = 0; ReactChildren.forEach(children, () => ++childCount); @@ -482,6 +501,8 @@ var TextInput = React.createClass({ style={[this.props.style]} autoCapitalize={autoCapitalize} autoCorrect={this.props.autoCorrect} + textAlign={textAlign} + textAlignVertical={textAlignVertical} keyboardType={this.props.keyboardType} multiline={this.props.multiline} onFocus={this._onFocus}