Regions of the text as objects

SyntaxEditor for Windows Forms Forum

Posted 10 years ago by AlexZ
Version: 13.1.0312
Avatar

I need to implement the behavior when a part of a text should be marked as an object. So the user can't delete or make other manipulations with the portion of this text - only the whole object.

I chose the ReadOnly Regions feature of SyntaxEditor. It allows me to create such regions of the text, but I can't delete them (or other operations). So, I created own classes to override the DeleteCommand and the BackspaceCommand to resolve the problem with deleting. In these classes I remove the read-only region and expand the selection before calling the base logic. This allows me to delete the whole text of this region.

But this action isn't restored by Undo command. So I have the problem with Undo command now. I mean, that Undo command doesn't restore the region.

Of course, there are other problems with these regions. For example, the problem with drag-n-drop operation..

Could you advise me more correct solution for my task or I should continue to customize other commands?

Thank you in advance.

Comments (2)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Alex,

For the undo situation, that is correct... it won't track read-only regions.  That means you would need to determine when to restore them yourself.  Couldn't you just watch the DocumentTextChanged event and look at the modification type?  If it is an Undo type, then you know you have to do some additional examination of the text to see if a region should be created again or not.


Actipro Software Support

Posted 10 years ago by AlexZ
Avatar

Thanks for the answer. Yes, I'm going to use the DocumentTextChange event. I just hoped that the editor had such behavior :)

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.