mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
Change TextInput onSelectionChange event data
This commit is contained in:
Vendored
+12
-1
@@ -1095,6 +1095,17 @@ export interface TextInputScrollEventData {
|
||||
contentOffset: { x: number; y: number; }
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TextInputProps.onSelectionChange
|
||||
*/
|
||||
export interface TextInputSelectionChangeEventData {
|
||||
selection: {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
target: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://facebook.github.io/react-native/docs/textinput.html#props
|
||||
*/
|
||||
@@ -1220,7 +1231,7 @@ export interface TextInputProps
|
||||
/**
|
||||
* Callback that is called when the text input selection is changed.
|
||||
*/
|
||||
onSelectionChange?: (event: { nativeEvent: { selection: { start: number; end: number }; target: number } }) => void;
|
||||
onSelectionChange?: (e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => void;
|
||||
|
||||
/**
|
||||
* Callback that is called when the text input's submit button is pressed.
|
||||
|
||||
@@ -56,7 +56,8 @@ import {
|
||||
StatusBar,
|
||||
NativeSyntheticEvent,
|
||||
GestureResponderEvent,
|
||||
TextInputScrollEventData
|
||||
TextInputScrollEventData,
|
||||
TextInputSelectionChangeEventData,
|
||||
} from "react-native";
|
||||
|
||||
declare module "react-native" {
|
||||
@@ -492,6 +493,14 @@ class TextInputTest extends React.Component<{}, {username: string}> {
|
||||
testNativeSyntheticEvent(e);
|
||||
}
|
||||
|
||||
handleOnSelectionChange = (e: NativeSyntheticEvent<TextInputSelectionChangeEventData>) => {
|
||||
testNativeSyntheticEvent(e);
|
||||
|
||||
console.log(`target: ${ e.nativeEvent.target }`);
|
||||
console.log(`start: ${ e.nativeEvent.selection.start }`);
|
||||
console.log(`end: ${ e.nativeEvent.selection.end }`);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
@@ -503,7 +512,7 @@ class TextInputTest extends React.Component<{}, {username: string}> {
|
||||
onChangeText={this.handleUsernameChange}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
<TextInput
|
||||
multiline
|
||||
onScroll={this.onScroll}
|
||||
/>
|
||||
@@ -512,6 +521,10 @@ class TextInputTest extends React.Component<{}, {username: string}> {
|
||||
onBlur={this.handleOnBlur}
|
||||
onFocus={this.handleOnFocus}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
onSelectionChange={this.handleOnSelectionChange}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user