From 17a4384d120e8bc242f2f0d6c3559609e7547030 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 23 May 2016 15:35:17 +0200 Subject: iOS: ensure we don't break UIKit IM state when sending key events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to be careful about calling textDidChange on the input delegate, since that will reset the internal IM state in UIKit and stop any ongoing text composition or spell checking. For that reason we set m_inSendEventToFocusObject to true whenever we send an IM event to Qt, to not call the abovementioned method when callbacks from UIKit is the reason for changing the text. But until now we never applied the same protection for key events. This lead to ligatures not working correctly (e.g when using Korean IM), since UIKit composes ligatures by first selecting the characters that can be truncated, then do a deleteBackwards, then insert the ligature. And deleteBackwards leads us to send backspace key events, which ends up in a textDidChange call, which confuses UIKit. This patch will ensure we don't call textDidChange as a result of sending key events. Task-number: QTBUG-52486 Change-Id: Ida268edae517f55a5b5f975340a5d3821f7b8f52 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostextresponder.mm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 320b1cac61..0cf505930f 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -353,6 +353,7 @@ - (void)sendKeyPressRelease:(Qt::Key)key modifiers:(Qt::KeyboardModifiers)modifiers { + QScopedValueRollback rollback(m_inSendEventToFocusObject, true); QWindowSystemInterface::handleKeyEvent(qApp->focusWindow(), QEvent::KeyPress, key, modifiers); QWindowSystemInterface::handleKeyEvent(qApp->focusWindow(), QEvent::KeyRelease, key, modifiers); QWindowSystemInterface::flushWindowSystemEvents(); -- cgit v1.2.3