text edit: Support enter key

It turns out inputMethodHints() is sort of a user setting; when
querying the hints in inputMethodQuery(), QQuickTextEdit adds the
Qt::ImMultiLine flag manually.
This commit is contained in:
Peter Hartmann 2025-01-14 10:25:17 +01:00
parent 1b4176625b
commit 3da81d185a
2 changed files with 16 additions and 2 deletions

View File

@ -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

View File

@ -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