diff options
author | Pekka Gehör <pekka.gehor@qt.io> | 2021-02-24 14:22:49 +0200 |
---|---|---|
committer | Pekka Gehör <pekka.gehor@qt.io> | 2021-05-25 08:45:39 +0300 |
commit | 32cdf0ce0faaeb6fe8bbc2f3df27a597c0bb8a55 (patch) | |
tree | 2f95b1f1a1ade182964ecf1507e188c6c1625653 /src/android | |
parent | 13c8db52a2e16ba525396bb7853de94ac50d6acf (diff) |
Android: Fix select handles misplacement on QDialog
Get select handles {Left, Right}Point from a mapToGlobal with a cursorRectangleof anchorRectangle
of the selected word/text.
Task-number: QTBUG-90799
Change-Id: I4fed19a1d3bb2247656b052306307e6980074405
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Diffstat (limited to 'src/android')
3 files changed, 21 insertions, 0 deletions
diff --git a/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java b/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java index dbadf7502d..980b172444 100644 --- a/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java +++ b/src/android/jar/src/org/qtproject/qt/android/CursorHandle.java @@ -202,6 +202,11 @@ public class CursorHandle implements ViewTreeObserver.OnPreDrawListener } } + public int width() + { + return m_cursorView.getDrawable().getIntrinsicWidth(); + } + // The handle was dragged by a given relative position public void updatePosition(int x, int y) { y -= m_yShift; diff --git a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java index d8456e7554..82e87b0e9c 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtActivityDelegate.java @@ -513,6 +513,17 @@ public class QtActivityDelegate private static final int CursorHandleShowSelection = 2; private static final int CursorHandleShowEdit = 0x100; + public int getSelectHandleWidth() + { + int width = 0; + if (m_leftSelectionHandle != null && m_rightSelectionHandle != null) { + width = Math.max(m_leftSelectionHandle.width(), m_rightSelectionHandle.width()); + } else if (m_cursorHandle != null) { + width = m_cursorHandle.width(); + } + return width; + } + /* called from the C++ code when the position of the cursor or selection handles needs to be adjusted. mode is one of QAndroidInputContext::CursorHandleShowMode diff --git a/src/android/jar/src/org/qtproject/qt/android/QtNative.java b/src/android/jar/src/org/qtproject/qt/android/QtNative.java index f97874ee96..d221ff602e 100644 --- a/src/android/jar/src/org/qtproject/qt/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt/android/QtNative.java @@ -864,6 +864,11 @@ public class QtNative }); } + private static int getSelectHandleWidth() + { + return m_activityDelegate.getSelectHandleWidth(); + } + private static void updateHandles(final int mode, final int editX, final int editY, |