From fcab034bcb6fbc7fa4a4e4e8da998a57b8c354fb Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Wed, 15 Jan 2025 08:28:38 +0100 Subject: [PATCH] text edit: Support enter key (#503) It turns out inputMethodHints() is sort of a user setting; when querying the hints in inputMethodQuery(), QQuickTextEdit adds the Qt::ImMultiLine flag manually. --- src/controls/QskTextEdit.cpp | 9 ++++++++- src/controls/QskTextInput.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/controls/QskTextEdit.cpp b/src/controls/QskTextEdit.cpp index 87e3949d..fd8cf3d2 100644 --- a/src/controls/QskTextEdit.cpp +++ b/src/controls/QskTextEdit.cpp @@ -294,13 +294,20 @@ void QskTextEdit::keyPressEvent( QKeyEvent* event ) { QGuiApplication::inputMethod()->commit(); - if ( !( inputMethodHints() & Qt::ImhMultiLine ) ) + const auto hints = inputMethodQuery( Qt::ImHints ).toInt(); + + if ( hints & Qt::ImhMultiLine ) + { + m_data->wrappedEdit->handleEvent( event ); + } + else { setEditing( false ); // When returning from a virtual keyboard qskForceActiveFocus( this, Qt::PopupFocusReason ); } + break; } #if 1 diff --git a/src/controls/QskTextInput.cpp b/src/controls/QskTextInput.cpp index eff363ae..05181f5f 100644 --- a/src/controls/QskTextInput.cpp +++ b/src/controls/QskTextInput.cpp @@ -308,7 +308,13 @@ void QskTextInput::keyPressEvent( QKeyEvent* event ) { QGuiApplication::inputMethod()->commit(); - if ( !( inputMethodHints() & Qt::ImhMultiLine ) ) + const auto hints = inputMethodQuery( Qt::ImHints ).toInt(); + + if ( hints & Qt::ImhMultiLine ) + { + m_data->wrappedInput->handleEvent( event ); + } + else { setEditing( false ); @@ -316,6 +322,7 @@ void QskTextInput::keyPressEvent( QKeyEvent* event ) qskForceActiveFocus( this, Qt::PopupFocusReason ); } } + break; } #if 1