TextArea and Spell Checking?

While writing a desktop app that has a text area control on the window, i noticed that when i type in the TextArea that it is automatically making spelling offerings… uhh… How’d dat happen?

By the way is there a notion of Carriage Return / Line Feed / BackSpace that is dependant on the OS?

https://documentation.xojo.com/api/deprecated/textedit.html#textedit-allowspellchecking is enabled by default.
https://documentation.xojo.com/api/code_execution/end.htmlOfLine

That property/method seems only available to the TextEdit and not to the TextArea.

You I understand the EndOfLine constants but I do not know how to tell the text area how to interpret these…
i.e. Carriage Return moves the cursor to the beginning of the current line while line feed goes down one line.
(Sort of like a VT100 terminal emulation.)

TextArea is a subclass of TextEdit.

[quote=481580:@Brian O’Brien]You I understand the EndOfLine constants but I do not know how to tell the text area how to interpret these…
i.e. Carriage Return moves the cursor to the beginning of the current line while line feed goes down one line.
(Sort of like a VT100 terminal emulation.)[/quote]
You will need to write your own implementation for that in the KeyDown or KeyUp handler. Which handler you use will change the feel of the operation.

It is also listed here: https://documentation.xojo.com/api/deprecated/textarea.html

MainWindow.STerminalEmulatorSet.Open, line 1 Type "TerminalEmulator" has no member named "AllowSpellChecking" STerminalEmulatorSet(index).AllowSpellChecking = false

TerminalEmulator is a subclass of TextArea
And i have a control set on my mainwindow…
I Tried to set that property in the open event.

Thank you for the pointers to the docs… Yes I saw that they both have this method… but that isn’t allowing me to use it.

There seems to be no way for the application to know when a misspelled word has been corrected using the spell checking. This means that if all that is done in a text field is that correction, the app cannot know that it needs to save the new contents. A while ago I filed a feature request, <https://xojo.com/issue/58209>, about this issue. Something as simple as a new read-only property which the app could query would solve the issue.

Are you saying that when auto correct fixes spelling the TextChanged event does not happen?

No. But the TextChange event fires with every keystroke and there isn’t any way I can find to identify that the change was from a spell check correction.

No… the event doesn’t occur? Or “no, the event occurs but I have this issue.”?
(I’m sorry, I just want to understand correctly!)

Unfortunately I don’t see anything in the Apple documentation that indicates that this information (that the change was due to system autocorrect) is available from the API. I am unsure about Windows.

Worst we can do is file a feedback request for it an be told it can’t be done. I’d say file a ticket and let the Xojo staff determine if they can include it. I’m not really suited to figure that out as a customer.

it DOES occur but all you know it “the text changed” instead of “the text changed because a spelling correction was made”

not sure why it would matter how the change was made but …

[quote=481766:@Norman Palardy]it DOES occur but all you know it “the text changed” instead of “the text changed because a spelling correction was made”

not sure why it would matter how the change was made but …[/quote]
Here’s a scenario…
Someone using the app to proofread a document and the only change made is a spellcheck correction on page 3 of a 75 page document. By the time the user finishes the last page he or she may have forgotten about the change and closes the document. The app doesn’t prompt for a save since there is no way for it to know that a spelling correction via the spellchecker was made. So the document closes and the correction is lost. Yes, I know it is ultimately the responsibility of the user to take care of it but a well-designed application should watch for it.

[quote=481765:@Tim Parnell]
Worst we can do is file a feedback request for it an be told it can’t be done. I’d say file a ticket and let the Xojo staff determine if they can include it. I’m not really suited to figure that out as a customer.[/quote]
I’ve already filed it as <https://xojo.com/issue/58209> but, so far, it isn’t ranked very high.

A 75 page document may be a bit much, but in all of my subclassed textfield/textarea controls I keep a copy of the original data that was loaded into the control, then compare against that to see if changes were made (actually have a “changed” computed property that does the comparison).

[quote=481971:@Dale Arends]Here’s a scenario…
Someone using the app to proofread a document and the only change made is a spellcheck correction on page 3 of a 75 page document. By the time the user finishes the last page he or she may have forgotten about the change and closes the document. The app doesn’t prompt for a save since there is no way for it to know that a spelling correction via the spellchecker was made…[/quote]

the textchanged event DOES fire if this occurs _ i tested this in 2019r1.1 and 2019r3.1
so you can know

[quote=481990:@Norman Palardy]the textchanged event DOES fire if this occurs _ i tested this in 2019r1.1 and 2019r3.1
so you can know[/quote]
Yes, it does, Norman. That’s not the point. (Actually, it’s ‘textchange’ not ‘textchanged’.) The point is that the textchange event fires for every keystroke also and there is no way to distinguish what caused it to fire, a keystroke or a spellcheck correction. That’s all I’m saying.

Generally, any change should be noted and the user prompted for a save regardless of what the change was.

well implement the keydown event handler
in the just set a boolean , mWasKeyDown, to true
then in text change if thats true you know it came from a keydown - and can act accordingly
and the boolean to false in there

if you land in a text change and that boolean is false then it was “something else” - like a spelling correction
and there are ways to make it so you know if it was a cut, paste etc as well

[quote=482174:@Norman Palardy]well implement the keydown event handler
in the just set a boolean , mWasKeyDown, to true
then in text change if thats true you know it came from a keydown - and can act accordingly
and the boolean to false in there

if you land in a text change and that boolean is false then it was “something else” - like a spelling correction
and there are ways to make it so you know if it was a cut, paste etc as well[/quote]
Yeah, I haven’t even gotten to the cut and paste aspect yet, or the drop text capability.

For those who are curious, the reason I need to determine these aspects is that the customer wants to be able to track how many of what type of edits are made by the proofreaders. I didn’t ask why…they’re the customer.

And while we’re on the subject, the spellchecking popup menu allows for adding the word to the dictionary. What dictionary and where is it? Can the user create his or her own dictionary?

on the mac this is most likely the ones built into the OS

I’ve never tried making my own but I suppose it might be possible
https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/DictionaryServicesProgGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40006152-CH1-DontLinkElementID_23

to catch things like cut and paste you’ll probably need a subclass
see my blog for “Subclasses are your friends”
the advice in that post holds true for text areas since the built in item already handles copy paste etc and you will need to override those behaviours