/** Moves the mouse-cursor, injects a mouse-move event and repositions the image. */ private void moveCursor(float newX, float newY) { synchronized (mRenderData) { // Constrain cursor to the image area. if (newX < 0) newX = 0; if (newY < 0) newY = 0; if (newX > mRenderData.imageWidth) newX = mRenderData.imageWidth; if (newY > mRenderData.imageHeight) newY = mRenderData.imageHeight; mCursorPosition.set(newX, newY); repositionImage(); } mViewer.injectMouseEvent((int) newX, (int) newY, BUTTON_UNDEFINED, false); }
/** Injects a button event using the current cursor location. */ private void injectButtonEvent(int button, boolean pressed) { mViewer.injectMouseEvent((int) mCursorPosition.x, (int) mCursorPosition.y, button, pressed); }