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

Create Custom Commands

1 Answer 101 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Subodh
Top achievements
Rank 2
Subodh asked on 25 May 2009, 09:05 AM
I want to create custom command without creating a custom tool.
I want to create custom command like InsertCleanParagraph which will be executed when user press the Ctrl+Enter.

The rad editor has  NewLineBr="false"

So when I press Ctrl+Enter in RAD editor it should insert
<p style="clear:both"></p>

When I press Shift+Enter it should insert
<br/>   Which is done by default command InsertParagraph

But I don't want any tool button to appear for this new command.

Please tell me how can I do this.

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 28 May 2009, 06:56 AM
Hello Subodh,

Here is a code example, which you can further enhance to fit your scenario:

 <script type="text/javascript"
 function OnClientLoad(editor) 
 { 
     editor.attachEventHandler("onkeydown"function(eventArgs) 
          { 
              var key = eventArgs.keyCode; 
              var ctrl = eventArgs.ctrlKey; 
              if (ctrl && key == "13"
              { 
                //alert("ctrl+Enter was pressed"); 
                editor.pasteHtml("<p style='clear:both'></p>"); 
                return false
              } 
              if (key == "13"
              { 
                //alert("Enter was pressed"); 
                editor.pasteHtml("<br/>"); 
                $telerik.cancelRawEvent(eventArgs); 
              } 
          } 
     ); 
   
    return false
 } 
</script> 
<telerik:RadEditor ID="RadEditor1" NewLineBr="false" OnClientLoad="OnClientLoad" runat="server"></telerik:RadEditor> 


Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Subodh
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Share this question
or