Android: Fix cursorHandle and EditPopup positions
After the commit 28df9a49776a88cb1a8e69348ae19a59b16a5b7e, a regression occurred in the positioning of cursorHandle and EditPopup. Previously, these positions were calculated using QtEditText coordinates, which worked correctly because the QtEditText size matched the QtWindow size. However, after the mentioned commit, the QtEditText size no longer reflects the window size. In this case, we need to use the parent View for calculations. This adjustment was already made for the single cursorHandle. This commit also updates the positioning of selection handles and the EditPopup. Fixes: QTBUG-132589 Pick-to: 6.9 6.8 Change-Id: I861292e363452d487284e3f603fe03a21a334aa4 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
8609982791
commit
5bd26fda7a
@ -135,7 +135,15 @@ class CursorHandle implements ViewTreeObserver.OnPreDrawListener
|
||||
initOverlay();
|
||||
|
||||
final int[] layoutLocation = new int[2];
|
||||
m_layout.getLocationOnScreen(layoutLocation);
|
||||
|
||||
// m_layout is QtEditText. Since it doesn't match the QtWindow size, we should use its
|
||||
// parent for cursorHandle positioning. However, there may be cases where the parent is
|
||||
// not set. In such cases, we need to use QtEditText instead.
|
||||
View positioningView = (View) m_layout.getParent();
|
||||
if (positioningView == null)
|
||||
positioningView = m_layout;
|
||||
|
||||
positioningView.getLocationOnScreen(layoutLocation);
|
||||
|
||||
// These values are used for handling split screen case
|
||||
final int[] activityLocation = new int[2];
|
||||
@ -158,7 +166,7 @@ class CursorHandle implements ViewTreeObserver.OnPreDrawListener
|
||||
m_popup.update(x2, y2, -1, -1);
|
||||
m_cursorView.adjusted(x - m_posX, y - m_posY);
|
||||
} else {
|
||||
m_popup.showAtLocation(m_layout, 0, x2, y2);
|
||||
m_popup.showAtLocation(positioningView, 0, x2, y2);
|
||||
}
|
||||
|
||||
m_posX = x;
|
||||
|
@ -57,7 +57,14 @@ class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.OnLayout
|
||||
Point viewSize = m_view.getCalculatedSize();
|
||||
|
||||
final int[] layoutLocation = new int[2];
|
||||
m_editText.getLocationOnScreen(layoutLocation);
|
||||
|
||||
// Since QtEditText doesn't match the QtWindow size, we should use its parent for
|
||||
// EditPopupMenu positioning. However, there may be cases where the parent is
|
||||
// not set. In such cases, we need to use QtEditText instead.
|
||||
View positioningView = (View) m_editText.getParent();
|
||||
if (positioningView == null)
|
||||
positioningView = m_editText;
|
||||
positioningView.getLocationOnScreen(layoutLocation);
|
||||
|
||||
// These values are used for handling split screen case
|
||||
final int[] activityLocation = new int[2];
|
||||
@ -87,8 +94,8 @@ class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.OnLayout
|
||||
}
|
||||
}
|
||||
|
||||
if (m_editText.getWidth() < x + viewSize.x / 2)
|
||||
x2 = m_editText.getWidth() - viewSize.x;
|
||||
if (positioningView.getWidth() < x + viewSize.x / 2)
|
||||
x2 = positioningView.getWidth() - viewSize.x;
|
||||
|
||||
if (x2 < 0)
|
||||
x2 = 0;
|
||||
@ -96,7 +103,7 @@ class EditPopupMenu implements ViewTreeObserver.OnPreDrawListener, View.OnLayout
|
||||
if (m_popup.isShowing())
|
||||
m_popup.update(x2, y2, -1, -1);
|
||||
else
|
||||
m_popup.showAtLocation(m_editText, 0, x2, y2);
|
||||
m_popup.showAtLocation(positioningView, 0, x2, y2);
|
||||
|
||||
m_posX = x;
|
||||
m_posY = y;
|
||||
|
@ -269,7 +269,7 @@ class QtEditText extends View
|
||||
break;
|
||||
case CursorHandleShowNormal:
|
||||
if (m_cursorHandle == null) {
|
||||
m_cursorHandle = new CursorHandle((Activity) getContext(), (View) getParent(),
|
||||
m_cursorHandle = new CursorHandle((Activity) getContext(), this,
|
||||
CursorHandle.IdCursorHandle,
|
||||
android.R.attr.textSelectHandle, false);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user