mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-06 17:27:54 +08:00
- [ReactNative] Remove pushNotification prop from renderApplication | Eric Vicenti - [react_native] Stub VibrationIOS on Android | Andy Street - [ReactNative] Simplify and test interpolators | Christopher Chedeau - [ReactNative] Increase timeout for obj-c tests | Christopher Chedeau - [ReactNative] Updated RKText to new UIManager system | Nick Lockwood - [ReactNative] Unforked RCTShadowView, moved RKTextView into FBReactKitTextModule | Nick Lockwood - [ReactKit] Remove NativeModulesDeprecated | Spencer Ahrens - [ReactNative] Allow single callbacks in NativeModules | Spencer Ahrens - [ReactNative] s/RK/RCT in OSS | Spencer Ahrens - [ReactNative] Cleanup StyleSheet API | Christopher Chedeau - [RCTVibration] Basic Vibration API | Christopher Chedeau - [React Native] Prevent crash in redbox code with two thrown errors | Ben Alpert - [ReactNative] unbreak Android | Andrew Rasmussen
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
*
|
|
* @providesModule TextInputState
|
|
*
|
|
* This class is responsible for coordinating the "focused"
|
|
* state for TextInputs. All calls relating to the keyboard
|
|
* should be funneled through here
|
|
*/
|
|
'use strict';
|
|
|
|
var RCTUIManager = require('NativeModules').RCTUIManager;
|
|
|
|
var TextInputState = {
|
|
/**
|
|
* Internal state
|
|
*/
|
|
_currentlyFocusedID: null,
|
|
|
|
/**
|
|
* Returns the ID of the currently focused text field, if one exists
|
|
* If no text field is focused it returns null
|
|
*/
|
|
currentlyFocusedField: function() {
|
|
return this._currentlyFocusedID;
|
|
},
|
|
|
|
/**
|
|
* @param {string} TextInputID id of the text field to focus
|
|
* Focuses the specified text field
|
|
* noop if the text field was already focused
|
|
*/
|
|
focusTextInput: function(textFieldID) {
|
|
if (this._currentlyFocusedID != textFieldID && textFieldID != null) {
|
|
this._currentlyFocusedID = textFieldID;
|
|
RCTUIManager.focus(textFieldID);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @param {string} textFieldID id of the text field to focus
|
|
* Unfocuses the specified text field
|
|
* noop if it wasn't focused
|
|
*/
|
|
blurTextInput: function(textFieldID) {
|
|
if (this._currentlyFocusedID == textFieldID && textFieldID != null) {
|
|
this._currentlyFocusedID = null;
|
|
RCTUIManager.blur(textFieldID);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = TextInputState;
|