mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-01-12 22:51:09 +08:00
@@ -87,6 +87,11 @@ as an argument to the callback handler.
|
||||
|
||||
Callback that is called when the text input is focused.
|
||||
|
||||
**onKeyPress**: function
|
||||
|
||||
Callback that is called when a key is pressed. Pressed key value is passed as
|
||||
an argument to the callback handler. Fires before `onChange` callbacks.
|
||||
|
||||
(web) **onSelectionChange**: function
|
||||
|
||||
Callback that is called when the text input's selection changes. The following
|
||||
|
||||
@@ -35,6 +35,7 @@ class TextInput extends Component {
|
||||
onChange: PropTypes.func,
|
||||
onChangeText: PropTypes.func,
|
||||
onFocus: PropTypes.func,
|
||||
onKeyPress: PropTypes.func,
|
||||
onSelectionChange: PropTypes.func,
|
||||
placeholder: PropTypes.string,
|
||||
placeholderTextColor: PropTypes.string,
|
||||
@@ -87,6 +88,7 @@ class TextInput extends Component {
|
||||
maxNumberOfLines,
|
||||
multiline,
|
||||
numberOfLines,
|
||||
onKeyPress,
|
||||
onLayout,
|
||||
onSelectionChange,
|
||||
placeholder,
|
||||
@@ -139,6 +141,7 @@ class TextInput extends Component {
|
||||
onBlur: this._handleBlur,
|
||||
onChange: this._handleChange,
|
||||
onFocus: this._handleFocus,
|
||||
onKeyPress,
|
||||
onSelect: onSelectionChange && this._handleSelectionChange,
|
||||
readOnly: !editable,
|
||||
ref: this._setInputRef,
|
||||
@@ -200,6 +203,7 @@ class TextInput extends Component {
|
||||
_handleChange = (e) => {
|
||||
const { onChange, onChangeText } = this.props;
|
||||
const text = e.target.value;
|
||||
e.nativeEvent.text = text;
|
||||
this.setState({ showPlaceholder: text === '' });
|
||||
if (onChange) { onChange(e); }
|
||||
if (onChangeText) { onChangeText(text); }
|
||||
|
||||
Reference in New Issue
Block a user