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>bb10
parent
78d0b6e975
commit
a04629d9c2
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue