From 306b9a87090ba4c4cc8453ef04f230620e224fe0 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 25 Apr 2018 17:52:31 +0000 Subject: Fix behavior of Delete key in XFA edit. Delete had two issues: it acted as a backspace that did not move the caret; delete was considered a valid char to insert in the character buffer. Bug: chromium:820104 Change-Id: I869eedcbf369b9b1df79f16285d991b8e630cd05 Reviewed-on: https://pdfium-review.googlesource.com/31291 Reviewed-by: dsinclair Commit-Queue: Henrique Nakashima --- xfa/fwl/cfwl_edit.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'xfa') diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 871aa3c6bf..afa9aac87d 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -1224,10 +1224,7 @@ void CFWL_Edit::OnKeyDown(CFWL_MessageKey* pMsg) { break; } - if (m_CursorPosition > 0) { - SetCursorPosition(m_EdtEngine.GetIndexBefore(m_CursorPosition)); - m_EdtEngine.Delete(m_CursorPosition, 1); - } + m_EdtEngine.Delete(m_CursorPosition, 1); break; } case FWL_VKEY_Insert: @@ -1253,20 +1250,21 @@ void CFWL_Edit::OnChar(CFWL_MessageKey* pMsg) { wchar_t c = static_cast(pMsg->m_dwKeyCode); switch (c) { - case FWL_VKEY_Back: + case L'\b': if (m_CursorPosition > 0) { SetCursorPosition(m_EdtEngine.GetIndexBefore(m_CursorPosition)); m_EdtEngine.Delete(m_CursorPosition, 1); } break; - case FWL_VKEY_NewLine: - case FWL_VKEY_Escape: + case L'\n': + case 27: // Esc + case 127: // Delete break; - case FWL_VKEY_Tab: + case L'\t': m_EdtEngine.Insert(m_CursorPosition, L"\t"); SetCursorPosition(m_CursorPosition + 1); break; - case FWL_VKEY_Return: + case L'\r': if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_WantReturn) { m_EdtEngine.Insert(m_CursorPosition, L"\n"); SetCursorPosition(m_CursorPosition + 1); -- cgit v1.2.3