Version: 4.0.5 (using KDE 4.0.5) Installed from: Fedora RPMs OS: Linux I am developing a new QInputContext. I use widget::inputMethodQuery (Qt::ImMicroFocus) to get current cursor pos. If there is not any preedit string, the returned cursor pos will be OK. If I set preedit string & cursor pos in preedit string via QInputContext::sendEvent, the returned cursor pos will be wrong, the cursor pos will point to the begin of the preedit string, it should be the cursor pos in preedit string. Please check it.
Created attachment 25449 [details] screenshot
Created attachment 25450 [details] screenshot, the cursor pos is correct in file open dialog of kwrite screenshot, the cursor pos is correct in file open dialog of kwrite
SVN commit 823329 by rodda: We're supposed to return the start position of the preedit, not the text cursor Please test, and if it's correct I'll backport it. BUG:164428 M +4 -1 kateviewinternal.cpp WebSVN link: http://websvn.kde.org/?view=rev&revision=823329
I just reviewed the commit 823329. You did not modified Qt::ImMicroFocus's return value. I tested dolphin and edit field in open dialog, I found: Qt::ImMicroFocus : return the cursor's position in widget. like: QVariant(QRect, QRect(133,2 10x16) ), It is cursor's coordinate in widget. Qt::Qt::ImCursorPosition : Return the logical position (or index) of the cursor within the text surrounding the input area. like: QVariant(int, 20), It's an int value. And the current preedit is QVariant(QString, "/home/phuangaaaaaaaa").
FYI. http://doc.trolltech.com/4.3/qt.html#InputMethodQuery-enum
I found KateViewInternal (http://websvn.kde.org/?view=rev&revision=823329) has a problem with IM. In inputMethodQuery method, Kate returns a point for Qt::ImCursorPosition. But I think it should return an integer value ( the index of current edit cursor in SurroundingText). Please below reference from Qt document. {{{ Qt::ImMicroFocus 0 The rectangle covering the area of the input cursor in widget coordinates. Qt::ImFont 1 The currently used font for text input. Qt::ImCursorPosition 2 The logical position of the cursor within the text surrounding the input area (see ImSurroundingText). Qt::ImSurroundingText 3 The plain text around the input area, for example the current paragraph. Qt::ImCurrentSelection 4 The currently selected text. }}}
Seems to be fixed in kate.git master: case Qt::ImCursorPosition: return m_imPreeditRange ? m_imPreeditRange->start().column() : 0; And otherwise the code looks ok, too, given your above statement what it should do from the Qt docs.