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.
This commit is contained in:
Peter Hartmann 2025-01-15 08:28:38 +01:00 committed by GitHub
parent 1b4176625b
commit fcab034bcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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