AutoCorrect and change detection

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Nicols C.
Avatar
Hi,

I am using SyntaxEditor to build an application like an IDE (like Visual Studio). I want to mark when a file is modified, so I use TextChanged event to be notified when a change is made.

Also, I have the feature AutoCorrect enabled. But, when I load a new Text if the text is autocorrected the event TextChanged is not trigger. So, I cannot identify if the text was autocorrected without comparing each character. I try to avoid this, because the texts are very long and could be inefficient.

Is there any other way to detect when the text changed with autocorrection?

Thanks,
Nicols

Comments (8)

Posted 14 years ago by Boyd - Automated Software Testing Consultant / Developer, Patterson Consulting, LLC
Avatar
I'm not sure about detecting when a document is modified for the initial auto-correct on load, but the Document class has a 'ModifiedChanged' event you can listen to to detect when it's been modified (better than using 'TextChanged' event).
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Every Document event also has a corresponding event on SyntaxEditor. In this case, you'd want to tie to SyntaxEditor.DocumentModifiedChanged. That way you can track whenever the Document.Modified property changes.


Actipro Software Support

Posted 14 years ago by Nicols C.
Avatar
Thanks, but I think that I was not clear enough.

I use TextChanged because I want to detect when the user press Undo to recover the "initial" state and mark the document as not modified.

For example if I follow this steps:
1) Set false to AutoCaseCorrectEnabled
2) Assign the text to SyntaxEditor
3) Set false to Modified
4) Set true to AutoCaseCorrectEnabled

When I set true to AutoCaseCorrectEnabled the text is autocorrected and it changed, but neither DocumentModifiedChanged nor TextChanged is fired.

Thanks,
Nicols
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The problem here is that with the current architecture of case correcting, it is intended to be a behind-the-scenes swap of text. Therefore it should only be used in case-insensitive languages like VB and really shouldn't be flipped on and off while editing a document.

It was intended to be set when a language that needed case correction was loaded. For instance if you load a VB document in visual studio, I believe it makes the case corrections without marking the document as modified. Are you following me here?

If I'm wrong with the architecture design here, please let me know but I believe this is correct design. Maybe what we need to do is raise another event like CaseCorrect that passes in a range of offsets in which case correction occurred. The range would probably encompass the offset of the first correction made through the end of the last correciton made. What do you think?


Actipro Software Support

Posted 14 years ago by Nicols C.
Avatar
Thanks for your response.

Reading your response I felt curious about how Visual Studio handle this case. I created a VB file with notepad and I opened it in VS. The file was not autocorrected until I modified the line which needs autocorrection. This way, the document is not marked as modified until you make a modification, and the autocorrect feature only autocorrect the line that you modified.

The Visual Studio behavior is right for me. Also, the event that you suggest would allow me to solve the problem. But I think that I prefer the Visual Studio way.

Nicols
Posted 14 years ago by Boyd - Automated Software Testing Consultant / Developer, Patterson Consulting, LLC
Avatar
I actually like the fact that it auto-corrects everything when the document is loaded, so perhaps there could be a property that indicates whether auto-correct should be performed on document load (default to True for backwards compatibility).
Posted 12 years ago by Thomas Goff
Avatar
Was this ever corrected/changed in the 3.x codebase? I also do not want the auto-case correct to be applied unless the user makes a modification. And even then I would only want the auto-case correct applied to the current line.

Thanks,
Tom
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Tom,

We've added a new property on Document for the next maintenance release called AutoCaseCorrectOnlyOnModification. It controls whether auto case correct only occurs after a modification takes place.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.