Last active
October 11, 2017 16:17
-
-
Save Palisand/af824464ea335327fd7f25eb441a3497 to your computer and use it in GitHub Desktop.
Changes for scroll-to-cursor functionality.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Event emitted by EditText native view when the text selection changes. | |
*/ | |
/* package */ class ReactTextInputSelectionEvent | |
extends Event<ReactTextInputSelectionEvent> { | |
private static final String EVENT_NAME = "topSelectionChange"; | |
private int mSelectionStart; | |
private int mSelectionEnd; | |
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ | |
private float mCursorPositionX; | |
private float mCursorPositionY; | |
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ | |
public ReactTextInputSelectionEvent( | |
int viewId, | |
int selectionStart, | |
int selectionEnd, | |
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ | |
float cursorPositionX, | |
float cursorPositionY) { | |
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ | |
super(viewId); | |
mSelectionStart = selectionStart; | |
mSelectionEnd = selectionEnd; | |
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ | |
mCursorPositionX = cursorPositionX; | |
mCursorPositionY = cursorPositionY; | |
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ | |
} | |
@Override | |
public String getEventName() { | |
return EVENT_NAME; | |
} | |
@Override | |
public void dispatch(RCTEventEmitter rctEventEmitter) { | |
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); | |
} | |
private WritableMap serializeEventData() { | |
WritableMap eventData = Arguments.createMap(); | |
WritableMap selectionData = Arguments.createMap(); | |
selectionData.putInt("end", mSelectionEnd); | |
selectionData.putInt("start", mSelectionStart); | |
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */ | |
selectionData.putDouble("cursorPositionX", mCursorPositionX); | |
selectionData.putDouble("cursorPositionY", mCursorPositionY); | |
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ | |
eventData.putMap("selection", selectionData); | |
return eventData; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment