input method handling improved

This commit is contained in:
Uwe Rathmann 2025-01-15 10:55:24 +01:00
parent fcab034bcb
commit 4d1513e5e5
3 changed files with 17 additions and 41 deletions

View File

@ -289,27 +289,6 @@ void QskTextEdit::keyPressEvent( QKeyEvent* event )
{ {
switch ( event->key() ) switch ( event->key() )
{ {
case Qt::Key_Enter:
case Qt::Key_Return:
{
QGuiApplication::inputMethod()->commit();
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 #if 1
case Qt::Key_Escape: case Qt::Key_Escape:
{ {

View File

@ -88,5 +88,3 @@ QSizeF QskTextEditSkinlet::sizeHint( const QskSkinnable* skinnable,
return hint; return hint;
} }
#include "moc_QskTextEditSkinlet.cpp"

View File

@ -304,22 +304,13 @@ void QskTextInput::keyPressEvent( QKeyEvent* event )
case Qt::Key_Enter: case Qt::Key_Enter:
case Qt::Key_Return: case Qt::Key_Return:
{ {
if ( hasAcceptableInput() || fixup() ) const auto hints = inputMethodQuery( Qt::ImHints ).toInt();
if ( !( hints & Qt::ImhMultiLine ) )
{ {
QGuiApplication::inputMethod()->commit(); if ( hasAcceptableInput() || fixup() )
const auto hints = inputMethodQuery( Qt::ImHints ).toInt();
if ( hints & Qt::ImhMultiLine )
{
m_data->wrappedInput->handleEvent( event );
}
else
{ {
QGuiApplication::inputMethod()->commit();
setEditing( false ); setEditing( false );
// When returning from a virtual keyboard
qskForceActiveFocus( this, Qt::PopupFocusReason );
} }
} }
@ -329,14 +320,19 @@ void QskTextInput::keyPressEvent( QKeyEvent* event )
case Qt::Key_Escape: case Qt::Key_Escape:
{ {
setEditing( false ); setEditing( false );
qskForceActiveFocus( this, Qt::PopupFocusReason );
break; break;
} }
#endif #endif
default: }
{
m_data->wrappedInput->handleEvent( event ); if ( isEditing() )
} {
m_data->wrappedInput->handleEvent( event );
}
else
{
// When returning from a virtual keyboard
qskForceActiveFocus( this, Qt::PopupFocusReason );
} }
return; return;
@ -577,6 +573,9 @@ void QskTextInput::setReadOnly( bool on )
// we are killing user settings here ? // we are killing user settings here ?
input->setFlag( QQuickItem::ItemAcceptsInputMethod, !on ); input->setFlag( QQuickItem::ItemAcceptsInputMethod, !on );
qskUpdateInputMethod( this, Qt::ImEnabled ); qskUpdateInputMethod( this, Qt::ImEnabled );
#if 0
qskUpdateInputMethod( this, Qt::ImReadOnly ); // since 6.2
#endif
setSkinStateFlag( ReadOnly, on ); setSkinStateFlag( ReadOnly, on );
} }