diff options
Diffstat (limited to 'xfa/fwl')
-rw-r--r-- | xfa/fwl/cfwl_datetimepicker.h | 2 | ||||
-rw-r--r-- | xfa/fwl/cfwl_edit.cpp | 31 | ||||
-rw-r--r-- | xfa/fwl/cfwl_edit.h | 2 |
3 files changed, 19 insertions, 16 deletions
diff --git a/xfa/fwl/cfwl_datetimepicker.h b/xfa/fwl/cfwl_datetimepicker.h index 276fea451d..97c5cd196e 100644 --- a/xfa/fwl/cfwl_datetimepicker.h +++ b/xfa/fwl/cfwl_datetimepicker.h @@ -53,7 +53,7 @@ class CFWL_DateTimePicker : public CFWL_Widget { WideString GetEditText() const; bool HasSelection() const { return m_pEdit->HasSelection(); } - // Returns <start, end> indices of the selection. + // Returns <start, count> of the selection. std::pair<size_t, size_t> GetSelection() const { return m_pEdit->GetSelection(); } diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 1bec1503fc..426d46e761 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -481,10 +481,10 @@ void CFWL_Edit::DrawContent(CXFA_Graphics* pGraphics, bool bShowSel = !!(m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); if (bShowSel && m_EdtEngine.HasSelection()) { size_t sel_start; - size_t sel_end; - std::tie(sel_start, sel_end) = m_EdtEngine.GetSelection(); - std::vector<CFX_RectF> rects = m_EdtEngine.GetCharacterRectsInRange( - sel_start, sel_end - sel_start + 1); + size_t count; + std::tie(sel_start, count) = m_EdtEngine.GetSelection(); + std::vector<CFX_RectF> rects = + m_EdtEngine.GetCharacterRectsInRange(sel_start, count); CXFA_Path path; for (auto& rect : rects) { @@ -1237,11 +1237,11 @@ void CFWL_Edit::OnLButtonUp(CFWL_MessageMouse* pMsg) { void CFWL_Edit::OnButtonDoubleClick(CFWL_MessageMouse* pMsg) { size_t click_idx = m_EdtEngine.GetIndexForPoint(DeviceToEngine(pMsg->m_pos)); size_t start_idx; - size_t end_idx; - std::tie(start_idx, end_idx) = m_EdtEngine.BoundsForWordAt(click_idx); + size_t count; + std::tie(start_idx, count) = m_EdtEngine.BoundsForWordAt(click_idx); - m_EdtEngine.SetSelection(start_idx, end_idx); - m_CursorPosition = end_idx; + m_EdtEngine.SetSelection(start_idx, count); + m_CursorPosition = start_idx + count; RepaintRect(m_rtEngine); } @@ -1260,10 +1260,13 @@ void CFWL_Edit::OnMouseMove(CFWL_MessageMouse* pMsg) { SetCursorPosition(length); size_t sel_start; - size_t sel_end; - std::tie(sel_start, sel_end) = m_EdtEngine.GetSelection(); - m_EdtEngine.SetSelection(std::min(sel_start, m_CursorPosition), - std::max(sel_end, m_CursorPosition)); + size_t count; + std::tie(sel_start, count) = m_EdtEngine.GetSelection(); + size_t original_end = sel_start + count; + sel_start = std::min(sel_start, m_CursorPosition); + m_EdtEngine.SetSelection( + std::min(sel_start, m_CursorPosition), + std::max(original_end, m_CursorPosition) - sel_start); } void CFWL_Edit::OnKeyDown(CFWL_MessageKey* pMsg) { @@ -1273,8 +1276,8 @@ void CFWL_Edit::OnKeyDown(CFWL_MessageKey* pMsg) { size_t sel_start = m_CursorPosition; if (m_EdtEngine.HasSelection()) { size_t start_idx; - size_t end_idx; - std::tie(start_idx, end_idx) = m_EdtEngine.GetSelection(); + size_t count; + std::tie(start_idx, count) = m_EdtEngine.GetSelection(); sel_start = start_idx; } diff --git a/xfa/fwl/cfwl_edit.h b/xfa/fwl/cfwl_edit.h index e85baaaa38..cfebb25146 100644 --- a/xfa/fwl/cfwl_edit.h +++ b/xfa/fwl/cfwl_edit.h @@ -74,7 +74,7 @@ class CFWL_Edit : public CFWL_Widget, public CFDE_TextEditEngine::Delegate { void SelectAll(); void ClearSelection(); bool HasSelection() const; - // Returns <start, end> indices of the selection. + // Returns <start, count> of the selection. std::pair<size_t, size_t> GetSelection() const; int32_t GetLimit() const; |