summaryrefslogtreecommitdiffstats
path: root/src/android
diff options
context:
space:
mode:
authorVova Mshanetskiy <vovams163@gmail.com>2019-04-25 18:39:38 +0300
committerVova Mshanetskiy <vovams163@gmail.com>2019-05-01 12:10:50 +0000
commita04629d9c2afb0e075a8872793718832200ea26b (patch)
tree5a45c50a75d87cfaf42d4d4ee198172642e0b0ae /src/android
parent78d0b6e9756c732bf0a7b02d258313a1d2ab461e (diff)
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 <bogdan@kdab.com>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/CursorHandle.java6
1 files 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()) {