From 4fa3c6e5b748c1cea7f2023faef69a16ff651bbd Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Wed, 15 Jan 2025 12:28:22 +0100 Subject: [PATCH] fixing unwanted side effects of input method events --- src/controls/QskTextInput.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/controls/QskTextInput.cpp b/src/controls/QskTextInput.cpp index 1f32c7b2..1d0e750a 100644 --- a/src/controls/QskTextInput.cpp +++ b/src/controls/QskTextInput.cpp @@ -35,7 +35,7 @@ static inline void qskPropagateReadOnly( QskTextInput* input ) } static inline void qskTranslateMouseEventPosition( - QMouseEvent* mouseEvent, const QPointF& offset ) + QMouseEvent* mouseEvent, const QPointF& offset ) { #if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) auto& point = mouseEvent->point(0); @@ -142,6 +142,27 @@ namespace break; } + case QEvent::InputMethod: + { + const bool hadCursor = isCursorVisible(); + + ok = this->event( event ); + + if ( isCursorVisible() && !hadCursor ) + { + /* + The initial InputMethod events might be sent from the + platform depending on focus. Unfortunately an + empty dummy event ( = no attributes ) leads to showing + the cursor. + */ + auto input = static_cast< const QskTextInput* >( parentItem() ); + if ( !input->isEditing() ) + setCursorVisible( false ); + } + + break; + } default: ok = this->event( event ); }