summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_fftextedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/cxfa_fftextedit.cpp')
-rw-r--r--xfa/fxfa/cxfa_fftextedit.cpp48
1 files changed, 21 insertions, 27 deletions
diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp
index 02787d579b..a8080d13d5 100644
--- a/xfa/fxfa/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/cxfa_fftextedit.cpp
@@ -11,7 +11,7 @@
#include "xfa/fwl/cfwl_datetimepicker.h"
#include "xfa/fwl/cfwl_edit.h"
#include "xfa/fwl/cfwl_eventtarget.h"
-#include "xfa/fwl/cfwl_eventtextchanged.h"
+#include "xfa/fwl/cfwl_eventtextwillchange.h"
#include "xfa/fwl/cfwl_messagekillfocus.h"
#include "xfa/fwl/cfwl_messagesetfocus.h"
#include "xfa/fwl/cfwl_notedriver.h"
@@ -287,7 +287,7 @@ bool CXFA_FFTextEdit::UpdateFWLData() {
WideString wsText = m_pNode->GetValue(eType);
WideString wsOldText = pEdit->GetText();
if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) {
- pEdit->SetText(wsText);
+ pEdit->SetText(wsText, CFDE_TextEditEngine::RecordOperation::kSkipNotify);
bUpdate = true;
}
if (bUpdate)
@@ -296,28 +296,26 @@ bool CXFA_FFTextEdit::UpdateFWLData() {
return true;
}
-void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget,
- const WideString& wsChanged,
- const WideString& wsPrevText) {
+void CXFA_FFTextEdit::OnTextWillChange(CFWL_Widget* pWidget,
+ CFWL_EventTextWillChange* event) {
m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged;
+
CXFA_EventParam eParam;
eParam.m_eType = XFA_EVENT_Change;
- eParam.m_wsChange = wsChanged;
+ eParam.m_wsChange = event->change_text;
eParam.m_pTarget = m_pNode.Get();
- eParam.m_wsPrevText = wsPrevText;
- if (m_pNode->GetFFWidgetType() == XFA_FFWidgetType::kDateTimeEdit) {
- auto* pDateTime = static_cast<CFWL_DateTimePicker*>(m_pNormalWidget.get());
- if (pDateTime->HasSelection()) {
- size_t count;
- std::tie(eParam.m_iSelStart, count) = pDateTime->GetSelection();
- eParam.m_iSelEnd = eParam.m_iSelStart + count;
- }
- } else {
- CFWL_Edit* pEdit = ToEdit(m_pNormalWidget.get());
- if (pEdit->HasSelection())
- std::tie(eParam.m_iSelStart, eParam.m_iSelEnd) = pEdit->GetSelection();
- }
+ eParam.m_wsPrevText = event->previous_text;
+ eParam.m_iSelStart = static_cast<int32_t>(event->selection_start);
+ eParam.m_iSelEnd = static_cast<int32_t>(event->selection_end);
+
m_pNode->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, &eParam);
+
+ // Copy the data back out of the EventParam and into the TextChanged event so
+ // it can propagate back to the calling widget.
+ event->cancelled = eParam.m_bCancelAction;
+ event->change_text = eParam.m_wsChange;
+ event->selection_start = static_cast<size_t>(eParam.m_iSelStart);
+ event->selection_end = static_cast<size_t>(eParam.m_iSelEnd);
}
void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) {
@@ -334,17 +332,13 @@ void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) {
void CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) {
CXFA_FFField::OnProcessEvent(pEvent);
switch (pEvent->GetType()) {
- case CFWL_Event::Type::TextChanged: {
- CFWL_EventTextChanged* event =
- static_cast<CFWL_EventTextChanged*>(pEvent);
- WideString wsChange;
- OnTextChanged(m_pNormalWidget.get(), wsChange, event->wsPrevText);
+ case CFWL_Event::Type::TextWillChange:
+ OnTextWillChange(m_pNormalWidget.get(),
+ static_cast<CFWL_EventTextWillChange*>(pEvent));
break;
- }
- case CFWL_Event::Type::TextFull: {
+ case CFWL_Event::Type::TextFull:
OnTextFull(m_pNormalWidget.get());
break;
- }
default:
break;
}