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

Darío Andrés andresbajotierra at gmail.com
Tue Jun 2 21:09:53 BST 2009


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.kde.org/r/790/
-----------------------------------------------------------

(Updated 2009-06-02 13:09:53.015551)


Review request for Kate and kdelibs.


Changes
-------

Adding Kate review group


Summary
-------

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.

Example:
- 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 https://bugs.kde.org/show_bug.cgi?id=179786 )

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.
    https://bugs.kde.org/show_bug.cgi?id=179786


Diffs
-----

  svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs/kdeui/widgets/ktextedit.cpp 975695 

Diff: http://reviewboard.kde.org/r/790/diff


Testing
-------

The bug is fixed. Minor drawback described above.


Thanks,

Darío





More information about the kde-core-devel mailing list