From 6c9cbcad62db2ff322cdf76a6d93325415025c8d Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 2 Mar 2021 16:17:56 +0100 Subject: [PATCH] text vw displayText to support text prediction --- src/controls/QskTextInput.cpp | 5 ++++- src/controls/QskTextInput.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controls/QskTextInput.cpp b/src/controls/QskTextInput.cpp index 6cd22859..a5daf338 100644 --- a/src/controls/QskTextInput.cpp +++ b/src/controls/QskTextInput.cpp @@ -33,6 +33,9 @@ static inline void qskBindSignals( QObject::connect( wrappedInput, &QQuickTextInput::textChanged, input, [ input ] { Q_EMIT input->textChanged( input->text() ); } ); + QObject::connect( wrappedInput, &QQuickTextInput::displayTextChanged, + input, [ input ] { Q_EMIT input->displayTextChanged( input->displayText() ); } ); + #if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 ) QObject::connect( wrappedInput, &QQuickTextInput::textEdited, input, [ input ] { Q_EMIT input->textEdited( input->text() ); } ); @@ -106,7 +109,7 @@ namespace if ( d->m_validator ) { - QString text = d->m_text; + QString text = displayText(); int pos = d->m_cursor; const auto state = d->m_validator->validate( text, pos ); diff --git a/src/controls/QskTextInput.h b/src/controls/QskTextInput.h index 769b271c..0ee9eb40 100644 --- a/src/controls/QskTextInput.h +++ b/src/controls/QskTextInput.h @@ -161,6 +161,7 @@ class QSK_EXPORT QskTextInput : public QskControl void readOnlyChanged( bool ); void textChanged( const QString& ); + void displayTextChanged( const QString& ); #if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 0 ) void textEdited( const QString& );