diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-03 21:16:49 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2019-05-05 00:57:19 +0200 |
commit | 110fd705ad3ae35144aaa6e5d8249b7e35f2825f (patch) | |
tree | c9c671c7d1b5706b483325942230e9642443371f /vcl/qt5/Qt5Widget.cxx | |
parent | 7889e35dedb15d55dfcacb1a388689e16a807834 (diff) |
tdf#123956 Qt5 IM update cursor position
This sets the cursor position to the one provided by the
QInputMethodEvent::Cursor attribute.
Change-Id: I4a99f9939b53c69631e45d41102bf9c7f53f0ff5
Reviewed-on: https://gerrit.libreoffice.org/71782
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/qt5/Qt5Widget.cxx')
-rw-r--r-- | vcl/qt5/Qt5Widget.cxx | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index f2c574a99655..1b5030f376ef 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -470,10 +470,32 @@ void Qt5Widget::inputMethodEvent(QInputMethodEvent* pEvent) { aInputEvent.maText = toOUString(pEvent->preeditString()); aInputEvent.mnCursorPos = 0; - sal_Int32 nLength = aInputEvent.maText.getLength(); + + const sal_Int32 nLength = aInputEvent.maText.getLength(); + const QList<QInputMethodEvent::Attribute>& rAttrList = pEvent->attributes(); std::vector<ExtTextInputAttr> aTextAttrs(nLength, ExtTextInputAttr::Underline); + + for (int i = 0; i < rAttrList.size(); ++i) + { + const QInputMethodEvent::Attribute& rAttr = rAttrList.at(i); + switch (rAttr.type) + { + case QInputMethodEvent::Cursor: + { + aInputEvent.mnCursorPos = rAttr.start; + if (rAttr.length == 0) + aInputEvent.mnCursorFlags |= EXTTEXTINPUT_CURSOR_INVISIBLE; + break; + } + default: + SAL_WARN("vcl.qt5", "Unhandled QInputMethodEvent attribute: " + << static_cast<int>(rAttr.type)); + break; + } + } if (nLength) aInputEvent.mpTextAttr = &aTextAttrs[0]; + m_pFrame->CallCallback(SalEvent::ExtTextInput, &aInputEvent); pEvent->accept(); } |