Hey Guys,
Can anyone point me toward the source code for KeyEvent?
I am trying to select text in a webview and would like to understand how the code i am using is working. Specifically, i would like to re-write it so that the select text implements a scroll when the user gets to the end of the view that is currently visible.
public void selectAndCopyText() {
try {
KeyEvent shiftPressEvent = new KeyEvent(0,0,
KeyEvent.ACTION_DOWN,KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
shiftPressEvent.dispatch(portal);
} catch (Exception e) {
throw new AssertionError(e);
}
}
In other words: using the code above or emulateshiftheld() makes it so that the user cant scroll. If the text that needs to be selected is not completely visible in the window, then the user has no way to copy and select all of the text.
What i would really like to know is how the KeyEvent is manipulating the text cursor and allowing the selection action to take place.