Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds return key type to TextInput #478

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Libraries/Components/TextInput/TextInput.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var RCTTextViewAttributes = merge(ReactIOSViewAttributes.UIView, {
fontStyle: true,
fontWeight: true,
keyboardType: true,
returnKeyType: true,
mostRecentEventCounter: true,
placeholder: true,
placeholderTextColor: true,
Expand Down Expand Up @@ -140,6 +141,22 @@ var TextInput = React.createClass({
'default',
'numeric',
]),
/**
* Determines the returnKeyType of the TextInput
**/
returnKeyType: PropTypes.oneOf([
'default',
'go',
'google',
'join',
'next',
'route',
'search',
'send',
'yahoo',
'done',
'emergencyCall',
]),
/**
* If true, the text input can be multiple lines. Default value is false.
*/
Expand Down Expand Up @@ -332,6 +349,7 @@ var TextInput = React.createClass({
style={[styles.input, this.props.style]}
enabled={this.props.editable}
keyboardType={this.props.keyboardType}
returnKeyType={this.props.returnKeyType}
onFocus={this._onFocus}
onBlur={this._onBlur}
onChange={this._onChange}
Expand Down
13 changes: 13 additions & 0 deletions React/Base/RCTConvert.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ + (NSURLRequest *)NSURLRequest:(id)json
@"default": @(UIKeyboardTypeDefault),
}), UIKeyboardTypeDefault, integerValue)

RCT_ENUM_CONVERTER(UIReturnKeyType, (@{
@"default": @(UIReturnKeyDefault),
@"go": @(UIReturnKeyGo),
@"google": @(UIReturnKeyGoogle),
@"join": @(UIReturnKeyJoin),
@"next": @(UIReturnKeyNext),
@"route": @(UIReturnKeyRoute),
@"search": @(UIReturnKeySearch),
@"send": @(UIReturnKeySend),
@"yahoo": @(UIReturnKeyYahoo),
@"done": @(UIReturnKeyDone),
}), UIReturnKeyDefault, integerValue)

RCT_ENUM_CONVERTER(UIViewContentMode, (@{
@"scale-to-fill": @(UIViewContentModeScaleToFill),
@"scale-aspect-fit": @(UIViewContentModeScaleAspectFit),
Expand Down
1 change: 0 additions & 1 deletion React/Views/RCTTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ - (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher
[self addTarget:self action:@selector(_textFieldEndEditing) forControlEvents:UIControlEventEditingDidEnd];
[self addTarget:self action:@selector(_textFieldSubmitEditing) forControlEvents:UIControlEventEditingDidEndOnExit];
_reactSubviews = [[NSMutableArray alloc] init];
self.returnKeyType = UIReturnKeyDone;
}
return self;
}
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTTextFieldManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ - (UIView *)view
RCT_EXPORT_VIEW_PROPERTY(text, NSString)
RCT_EXPORT_VIEW_PROPERTY(clearButtonMode, UITextFieldViewMode)
RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType)
RCT_EXPORT_VIEW_PROPERTY(returnKeyType, UIReturnKeyType)
RCT_REMAP_VIEW_PROPERTY(color, textColor, UIColor)
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, autocapitalizationType, UITextAutocapitalizationType)
RCT_CUSTOM_VIEW_PROPERTY(fontSize, CGFloat, RCTTextField)
Expand Down