The Task
--------
In the editor (specifically mail/news compose version), I am typing and when I hit <SPACE> I want to traverse back and grab the last typed word.
The Possible Solution
---------------------
1) Hook up another function (passing event) to the <editor> onkeypress handler.
2) Sniff out SPACE ... do nothing for all other chars typed:
if (event.keyCode == event.DOM_VK_SPACE) {
// get the word
}
3) Use one of the DOM Range interfaces to get the word. Which one, I am not sure (nsIDOMRange ...). Or use the editor document interface and adapt the code in editor.js/EditorSetSelectionFromOffsets. But I need to get the ranges first.
Does anyone have any tips on the solution ... am I going down the right path?
Tweaking the zibble of the editor is probably the easiest way to catch a whitespace key if you don't want to hack the c++.
Akkana told me on IRC there are ways to extend the selection (probably reduced to the caret in your case) to the previous/next word. Should be enough for what you need.
Am I right to suspect you want to implement spell/grammar checking on the fly as the user types, "� la MSFT" or something of that kind ? It that's the case, you also need to consider punctuation...
</Daniel>
_______________________________________________ mozilla-editor mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-editor
