mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-28 22:46:52 +08:00
[react-packager][streamline oss] Move open sourced JS source to react-native-github
This commit is contained in:
53
Libraries/Components/TextInput/TextInputState.js
Normal file
53
Libraries/Components/TextInput/TextInputState.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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 RKUIManager = require('NativeModulesDeprecated').RKUIManager;
|
||||
|
||||
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;
|
||||
RKUIManager.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;
|
||||
RKUIManager.blur(textFieldID);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = TextInputState;
|
||||
Reference in New Issue
Block a user