This is a migrated thread and some comments may be shown as answers.

Override RichTextBoxCommands

3 Answers 137 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 19 Nov 2014, 12:28 PM
Hi

I want to change the behaviour of certain commands - as one example, I want to be able to execute ChangePageOrientationCommand in a protected document.  The current value of CanExecuteBehaviorInProtectedDocument for that command is CanExecuteBehaviorInProtectedDocument.Never.

So, easy, right?  I can derive from ChangePageOrientationCommand and override CanExecuteBehaviorInProtectedDocument.  Done.

Then what I'd like to do is derive from RichTextBoxCommands, override the virtual ChangePageOrientationCommand and set the public Commands dependency property on RadRichTextBox... but I can't - the RichTextBoxCommands constructor is internal.

Is there an extensibility point I'm missing?  

While I could just instantiate this new command elsewhere and point by ribbon button to this, I'd also like to subtly change the behavior of InsertCommand and DeleteCommand (so they don't execute in certain scenarios).  This is much harder, as they're called internally by keyboard and mouse handling.

Thanks

Charlie

3 Answers, 1 is accepted

Sort by
0
Mihail
Telerik team
answered on 24 Nov 2014, 09:17 AM
Hello Charles,

I am afraid that creation of custom commands is not possible at this point. My suggestion for your scenario is to create your own command that will use the RadDocumentEditor to manipulate the document. RadDocumentEditor has properties like RespectDocumentProtection which will allow execution of its methods over protected document.

Could you provide more information on what exactly is your scenario with Insert and Delete commands and how you would like to change the way they are executed. This way we will be able to assist you better.


Regards,
Mihail
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Charles
Top achievements
Rank 1
answered on 24 Nov 2014, 02:43 PM
Thanks - I had managed use solutions similar to yours to get what I wanted, I just thought I'd ask in case there was a way I'd overlooked to replace the built-in commands.  It looks like all you'd need to do is change the constructor of RichTextBoxCommands from internal to public, but there may be have other implications for you that I haven't considered.

My aim was to create AnnotationRanges that were similar to ReadOnlyRange, but without all the restrictions.  I want to be able to select and format text as with non-readonly text, but just prevent changing their values (which I've done by cancelling commands that would result in changes via OnCommandExecuting).
0
Mihail
Telerik team
answered on 27 Nov 2014, 07:23 AM
Hello Charles,

The only suitable approach at this moment is the one you already found out. Working with RadDocumentEditor.

When it comes to restricting the Insert and Delete commands, subscribing to command executing event and canceling the commands in question, is the right way to do it.

Regards,
Mihail
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
RichTextBox
Asked by
Charles
Top achievements
Rank 1
Answers by
Mihail
Telerik team
Charles
Top achievements
Rank 1
Share this question
or