diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2016-06-09 10:38:17 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@theqtcompany.com> | 2016-06-17 09:41:02 +0000 |
commit | afc9e2d9674f7ab5800df4803cc68c71d1ae691a (patch) | |
tree | 6feb94fdddfddba80251e17172f2c8623d0224ef /src/core/render_widget_host_view_qt.cpp | |
parent | e263573db93c4e2cbf42e6d8d3508415f1354d50 (diff) |
Commit the done-so-far IME composition on mouse click.
Before this change, it was possible to select parts of the pre-edit
text in an ongoing IME composition, by click-dragging with the mouse
(which also looked wrong, because the styling of the text did not
change to a selection box to signal selection).
This is inconsistent with how Chrome does it, which commits the
pre-edit string entered so far, when clicking anywhere in the content
area or in the input.
This change makes sure to commit the pre-edit string when a mouse
click is done anywhere on the displayed web page.
The behavior was present on Windows and Linux.
Change-Id: I9cb148c591b5d09fb4dd477ae96c29ca32cc34de
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index bb024c557..ef7367e06 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -954,6 +954,19 @@ void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event) QCursor::setPos(m_lockedMousePosition); } + if (m_imeInProgress && event->type() == QMouseEvent::MouseButtonPress) { + m_imeInProgress = false; + // Tell input method to commit the pre-edit string entered so far, and finish the + // composition operation. +#ifdef Q_OS_WIN + // Yes the function name is counter-intuitive, but commit isn't actually implemented + // by the Windows QPA, and reset does exactly what is necessary in this case. + qApp->inputMethod()->reset(); +#else + qApp->inputMethod()->commit(); +#endif + } + m_host->ForwardMouseEvent(webEvent); } |