A
a_poster
I'm making a real-time spell checker that mimics MS Word's real-time spell
checking behavior. As the user types into a rich text box, I detect when a
word has been misspelled and modify the visual appearance of the word in
some way (currently I just turn it red).
So, using a rich text box, I have to :
a) bookmark my current .selectionStart into some integer
b) set .selectionStart to the beginning of the misspelled word
c) set .selectionLength to the end of the misspelled word
d) set .selectionColor = [red]
e) set .selectionStart = bookmarked position
I admit this works - the code's fairly efficient and the PC is fast, so I
can accomplish all this faster than anyone can realistically type and the
user has no idea their selection is running wild all over the textbox every
time they leave a word behind. But I had initially envisioned (not knowing
anything about the rich textbox control) a more elegant system of simply
pointing to a substring in the text and changing it's color, or font or
style or whatever, instantly, and without moving the cursor. Was that a
naive dream or is this possible to do without so much modification to the
selection?
checking behavior. As the user types into a rich text box, I detect when a
word has been misspelled and modify the visual appearance of the word in
some way (currently I just turn it red).
So, using a rich text box, I have to :
a) bookmark my current .selectionStart into some integer
b) set .selectionStart to the beginning of the misspelled word
c) set .selectionLength to the end of the misspelled word
d) set .selectionColor = [red]
e) set .selectionStart = bookmarked position
I admit this works - the code's fairly efficient and the PC is fast, so I
can accomplish all this faster than anyone can realistically type and the
user has no idea their selection is running wild all over the textbox every
time they leave a word behind. But I had initially envisioned (not knowing
anything about the rich textbox control) a more elegant system of simply
pointing to a substring in the text and changing it's color, or font or
style or whatever, instantly, and without moving the cursor. Was that a
naive dream or is this possible to do without so much modification to the
selection?