I have a requirement where I need to get the word that was typed in a contenteditable
div.
Whenever I type a word and hit space I want to know what word was typed. The word can be typed towards the end or anywhere on between.
I have a requirement where I need to get the word that was typed in a contenteditable
div.
Whenever I type a word and hit space I want to know what word was typed. The word can be typed towards the end or anywhere on between.
If you are using javascript then this stack overflow link is useful :
get the text content from a contenteditable div through javascript
In GWT I believe contentEditable
div refers to Textbox
, Numberbox
or RichTextArea
. (If any others are there, let me know).
The solution looks fairly simple.
You can easily override the onBrowseEvent()
for each of the above said widgets. Once the keystrokes matches either space or Enter
get the value from the div and store it in current value or any other string
. Maintain a previous value
String and compare with it. Once you encounter the first change in the String, you got word which you were looking for.
Hope this helps
You can use on keyUp event to check for space and than use a diff algorithm to check for changes made. see google for "javascript diff" algos - you will masses ....