Skip to content

Commit 41bea8d

Browse files
Merge pull request #8 from sinyo1015/add_submit
feat: add onsubmit listener on text field
2 parents 9d3b658 + 069bb43 commit 41bea8d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ class InputSpinner extends Component {
221221
this.onChange(num);
222222
}
223223

224+
/**
225+
* On Submit keyboard
226+
* @param NativeEvent
227+
* @returns {*}
228+
*/
229+
230+
onSubmit(e){
231+
this.props.onSubmit(this.parseNum(e.nativeEvent.text))
232+
}
233+
234+
224235
/**
225236
* Max is reached
226237
* @param num
@@ -649,6 +660,7 @@ class InputSpinner extends Component {
649660
editable={this.isEditable()}
650661
keyboardType={this._getKeyboardType()}
651662
onChangeText={this.onChange.bind(this)}
663+
onSubmitEditing={this.onSubmit.bind(this)}
652664
/>
653665

654666
{this.props.children}
@@ -693,6 +705,7 @@ InputSpinner.propTypes = {
693705
onMax: PropTypes.func,
694706
onIncrease: PropTypes.func,
695707
onDecrease: PropTypes.func,
708+
onSubmit : PropTypes.func,
696709
buttonLeftDisabled: PropTypes.bool,
697710
buttonRightDisabled: PropTypes.bool,
698711
buttonLeftText: PropTypes.string,

0 commit comments

Comments
 (0)