From a04629d9c2afb0e075a8872793718832200ea26b Mon Sep 17 00:00:00 2001 From: Vova Mshanetskiy Date: Thu, 25 Apr 2019 18:39:38 +0300 Subject: [PATCH] Android: Fix positioning of selection handles in text editors The old code used size of m_cursorView to calculate position of the cursor handle popup. But since on Android layout process is asynchronous, both width and height of m_cursorView was 0 upon first call to setPosition(). This resulted in selection handles being initially displayed at a wrong position for a fraction of second and then quickly moving to the correct position. In some cases handles stayed at the wrong position until touched by user. This patch replaces use of m_cursorView's size with use of m_popup's size. Width and height of m_popup may be used immediately because they are explicitly assigned in initOverlay(). The size of m_popup should be always equal to the would-be size of m_cursorView because of how it is calculated. Change-Id: I9868c9a5ce0103d8328b2478cf82feaceba7f404 Reviewed-by: BogDan Vatra --- .../jar/src/org/qtproject/qt5/android/CursorHandle.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java b/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java index 788a5c2b3d..38cc695c37 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java +++ b/src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java @@ -166,11 +166,11 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener int y2 = y + location[1] + m_yShift; if (m_id == QtNative.IdCursorHandle) { - x2 -= m_cursorView.getWidth() / 2 ; + x2 -= m_popup.getWidth() / 2 ; } else if ((m_id == QtNative.IdLeftHandle && !m_rtl) || (m_id == QtNative.IdRightHandle && m_rtl)) { - x2 -= m_cursorView.getWidth() * 3 / 4; + x2 -= m_popup.getWidth() * 3 / 4; } else { - x2 -= m_cursorView.getWidth() / 4; + x2 -= m_popup.getWidth() / 4; } if (m_popup.isShowing()) {