@Override
public boolean mouseMove(Component component, int x, int y) {
boolean consumed = super.mouseMove(component, x, y);
if (Mouse.getCapturer() == component) {
TextArea textArea = (TextArea)getComponent();
Bounds visibleArea = textArea.getVisibleArea();
visibleArea = new Bounds(visibleArea.x, visibleArea.y, visibleArea.width,
visibleArea.height);
// if it's inside the visible area, stop the scroll timer
if (y >= visibleArea.y
&& y < visibleArea.y + visibleArea.height) {
// Stop the scroll selection timer
if (scheduledScrollSelectionCallback != null) {
scheduledScrollSelectionCallback.cancel();
scheduledScrollSelectionCallback = null;
}
scrollDirection = null;
} else {
// if it's outside the visible area, start the scroll timer
if (scheduledScrollSelectionCallback == null) {
scrollDirection = (y < visibleArea.y) ? TextArea.ScrollDirection.UP
: TextArea.ScrollDirection.DOWN;
scheduledScrollSelectionCallback = ApplicationContext.scheduleRecurringCallback(
scrollSelectionCallback, SCROLL_RATE);
// Run the callback once now to scroll the selection immediately
scrollSelectionCallback.run();
}
}
int index = getInsertionPoint(x, y);
if (index != -1) {
// Select the range
if (index > anchor) {
textArea.setSelection(anchor, index - anchor);
} else {
textArea.setSelection(index, anchor - index);
}
}
mouseX = x;
} else {