Review Request: KTextEdit spellchecking highlight implementation fix on mouse right click near the word

Darío Andrés andresbajotierra at
Tue Jun 2 20:38:13 BST 2009

This is an automatically generated e-mail. To reply, visit:

Review request for kdelibs.


When you have a KTextEdit with automatic spell checking enabled, the mispelled words will be underlined with a red line.
If you click this mispelled words you will get a special context menu with the spellchecking options (Ignore, Add to Dict, Replace with...) instead of the default KTextEdit menu.

However, the current implementation on that code uses QTextEdit::cursorFromPosition(mousePosition) and this will lead to bad behaviours in some cases.

- If the last word or a sentence is mispelled, if you right-click to the right of that word (in the empty space) you would expect to get the default context menu (as the mouse cursor position is not over the mispelled word). HOWEVER, as the last character of the mispelled word is the last character of the sentence, "QTextEdit::cursorFromPosition(mousePosition)" will return the text cursor at the right of the word, the word will be selected and the spellchecking related menu will appear. ( This is also (and probably better) described at )

Proposed solution: check if the text-cursor position obtained by the mouse position cursor is on the limits of the word (ex. |mispeled|) , and do not react in that cases. So, if you click on the empty space (using the same situation as the example above), you will get the expected normal context menu (even if the sentence do not end with an empty space).
The drawback is that you will have to point the mouse cursor a bit towards the center of the word itself to allow "QTextEdit::cursorFromPosition(mousePosition)" to return a text-cursor position INSIDE the word. But I guess this is a minimal drawback as the original problem is much more annoying.

I have searched other methods to try to use the mousecursor coordinates(pixels) (to be more exact) but I couldn't get anything better.

This addresses bug 179786.


  svn:// 975695 



The bug is fixed. Minor drawback described above.



More information about the kde-core-devel mailing list