public class ReactEditText
extends AppCompatEditText
ReactEditTexts have setFocusableInTouchMode set to false automatically because touches on the EditText are managed on the JS side. This also removes the nasty side effect that EditTexts have, which is that focus is always maintained on one of the EditTexts.
The wrapper stops the EditText from triggering *TextChanged events, in the case where JS has
called this explicitly. This is the default behavior on other platforms as well.
VisibleForTesting from TextInputEventsTestCase
.
Modifier and Type | Field and Description |
---|---|
protected JavaOnlyMap |
mAttributedString |
protected boolean |
mContainsImages |
protected boolean |
mDisableTextDiffing |
protected boolean |
mIsSettingTextFromJS |
protected boolean |
mIsSettingTextFromState |
protected int |
mNativeEventCount
A count of events sent to JS or C++.
|
protected StateWrapper |
mStateWrapper |
Constructor and Description |
---|
ReactEditText(android.content.Context context) |
Modifier and Type | Method and Description |
---|---|
void |
addTextChangedListener(android.text.TextWatcher watcher) |
protected void |
applyTextAttributes() |
boolean |
canUpdateWithEventCount(int eventCounter) |
void |
clearFocus() |
boolean |
getBlurOnSubmit() |
boolean |
getDisableFullscreenUI() |
java.lang.String |
getReturnKeyType() |
protected void |
hideSoftKeyboard() |
int |
incrementAndGetEventCounter() |
void |
invalidateDrawable(android.graphics.drawable.Drawable drawable) |
boolean |
isLayoutRequested() |
void |
maybeSetSelection(int eventCounter,
int start,
int end)
Attempt to set a selection or fail silently.
|
void |
maybeSetText(ReactTextUpdate reactTextUpdate) |
void |
maybeSetTextFromJS(ReactTextUpdate reactTextUpdate) |
void |
maybeSetTextFromState(ReactTextUpdate reactTextUpdate) |
void |
maybeUpdateTypeface() |
void |
onAttachedToWindow() |
android.view.inputmethod.InputConnection |
onCreateInputConnection(android.view.inputmethod.EditorInfo outAttrs) |
void |
onDetachedFromWindow() |
void |
onFinishTemporaryDetach() |
protected void |
onFocusChanged(boolean focused,
int direction,
android.graphics.Rect previouslyFocusedRect) |
boolean |
onKeyUp(int keyCode,
android.view.KeyEvent event) |
protected void |
onLayout(boolean changed,
int left,
int top,
int right,
int bottom) |
protected void |
onScrollChanged(int horiz,
int vert,
int oldHoriz,
int oldVert) |
protected void |
onSelectionChanged(int selStart,
int selEnd) |
void |
onStartTemporaryDetach() |
boolean |
onTouchEvent(android.view.MotionEvent ev) |
void |
removeTextChangedListener(android.text.TextWatcher watcher) |
boolean |
requestFocus(int direction,
android.graphics.Rect previouslyFocusedRect) |
void |
requestFocusFromJS() |
void |
setAllowFontScaling(boolean allowFontScaling) |
void |
setAutoFocus(boolean autoFocus) |
void |
setBackgroundColor(int color) |
void |
setBlurOnSubmit(java.lang.Boolean blurOnSubmit) |
void |
setBorderColor(int position,
float color,
float alpha) |
void |
setBorderRadius(float borderRadius) |
void |
setBorderRadius(float borderRadius,
int position) |
void |
setBorderStyle(java.lang.String style) |
void |
setBorderWidth(int position,
float width) |
void |
setContentSizeWatcher(ContentSizeWatcher contentSizeWatcher) |
void |
setDisableFullscreenUI(boolean disableFullscreenUI) |
void |
setFontFamily(java.lang.String fontFamily) |
void |
setFontSize(float fontSize) |
void |
setFontStyle(java.lang.String fontStyleString) |
void |
setFontWeight(java.lang.String fontWeightString) |
void |
setInputType(int type) |
void |
setLetterSpacingPt(float letterSpacingPt) |
void |
setMaxFontSizeMultiplier(float maxFontSizeMultiplier) |
void |
setOnKeyPress(boolean onKeyPress) |
void |
setReturnKeyType(java.lang.String returnKeyType) |
void |
setScrollWatcher(ScrollWatcher scrollWatcher) |
void |
setSelection(int start,
int end) |
void |
setSelectionWatcher(com.facebook.react.views.textinput.SelectionWatcher selectionWatcher) |
protected boolean |
showSoftKeyboard() |
protected boolean |
verifyDrawable(android.graphics.drawable.Drawable drawable) |
protected boolean mIsSettingTextFromJS
protected int mNativeEventCount
protected boolean mContainsImages
protected JavaOnlyMap mAttributedString
protected StateWrapper mStateWrapper
protected boolean mDisableTextDiffing
protected boolean mIsSettingTextFromState
public boolean isLayoutRequested()
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
public boolean onTouchEvent(android.view.MotionEvent ev)
public boolean onKeyUp(int keyCode, android.view.KeyEvent event)
protected void onScrollChanged(int horiz, int vert, int oldHoriz, int oldVert)
public android.view.inputmethod.InputConnection onCreateInputConnection(android.view.inputmethod.EditorInfo outAttrs)
public void clearFocus()
public boolean requestFocus(int direction, android.graphics.Rect previouslyFocusedRect)
public void addTextChangedListener(android.text.TextWatcher watcher)
public void removeTextChangedListener(android.text.TextWatcher watcher)
public void setContentSizeWatcher(ContentSizeWatcher contentSizeWatcher)
public void setScrollWatcher(ScrollWatcher scrollWatcher)
public void maybeSetSelection(int eventCounter, int start, int end)
eventCounter
- start
- end
- public void setSelection(int start, int end)
protected void onSelectionChanged(int selStart, int selEnd)
protected void onFocusChanged(boolean focused, int direction, android.graphics.Rect previouslyFocusedRect)
public void setSelectionWatcher(com.facebook.react.views.textinput.SelectionWatcher selectionWatcher)
public void setBlurOnSubmit(java.lang.Boolean blurOnSubmit)
public void setOnKeyPress(boolean onKeyPress)
public boolean getBlurOnSubmit()
public void setDisableFullscreenUI(boolean disableFullscreenUI)
public boolean getDisableFullscreenUI()
public void setReturnKeyType(java.lang.String returnKeyType)
public java.lang.String getReturnKeyType()
public void setInputType(int type)
public void setFontFamily(java.lang.String fontFamily)
public void setFontWeight(java.lang.String fontWeightString)
public void setFontStyle(java.lang.String fontStyleString)
public void maybeUpdateTypeface()
public void requestFocusFromJS()
public int incrementAndGetEventCounter()
public void maybeSetTextFromJS(ReactTextUpdate reactTextUpdate)
public void maybeSetTextFromState(ReactTextUpdate reactTextUpdate)
public boolean canUpdateWithEventCount(int eventCounter)
public void maybeSetText(ReactTextUpdate reactTextUpdate)
protected boolean showSoftKeyboard()
protected void hideSoftKeyboard()
protected boolean verifyDrawable(android.graphics.drawable.Drawable drawable)
public void invalidateDrawable(android.graphics.drawable.Drawable drawable)
public void onDetachedFromWindow()
public void onStartTemporaryDetach()
public void onAttachedToWindow()
public void onFinishTemporaryDetach()
public void setBackgroundColor(int color)
public void setBorderWidth(int position, float width)
public void setBorderColor(int position, float color, float alpha)
public void setBorderRadius(float borderRadius)
public void setBorderRadius(float borderRadius, int position)
public void setBorderStyle(java.lang.String style)
public void setLetterSpacingPt(float letterSpacingPt)
public void setAllowFontScaling(boolean allowFontScaling)
public void setFontSize(float fontSize)
public void setMaxFontSizeMultiplier(float maxFontSizeMultiplier)
public void setAutoFocus(boolean autoFocus)
protected void applyTextAttributes()