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

Default context menu not visible

1 Answer 145 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Alien Interactive AB
Top achievements
Rank 1
Alien Interactive AB asked on 29 Jun 2020, 11:15 AM

I found an issue with the context menu. I tried in the demo to right click on an empty area/on a word and expects that the default context menu should show up with copy/paste etc... Only the native browser (Chrome 83) menu shows up. Shouldn't this work by default?

In my code i have been using this to add a custom menu, but it doesnt work due to the above issue i guess.
Is there any documentation how to add items for all tags, in the code below I use *, and seen other examples with BODY

MyRadEditor.EnsureToolsFileLoaded();
var contextMenu = MyRadEditor.ContextMenus.FindByTagName("*");

var editorTool = new EditorTool("Toolname");
editorTool.ShowIcon = false;
contextMenu.Tools.Add(editorTool);

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 01 Jul 2020, 08:05 AM

Hi Martin,

I hope you are doing well!

The reported scenario with the context menu is the default behavior of the Editor control - to show the Editor's context menu in Internet Explorer and the browser's context menu in the other browsers. 

This is because the browser's one contains not only the spelling suggestions but also the Cut, Copy and Paste commands work perfectly fine since they do not rely on JavaScript (which is often forbidden to perform paste operations due to security reasons). 

We received feedback from customers to enable the native context menu in that browsers so that they can use the browser spellchecker as well as to be able to paste directly without using Ctrl+V.

If you would like to enable the Editor's context menu in all browsers, you can do that easily by adding the ContextMenus inner tag collection below : 

<telerik:RadEditor RenderMode="Lightweight" ID="RadEditor1" runat="server">
    <ContextMenus>
        <telerik:EditorContextMenu TagName="BODY">
            <telerik:EditorTool Name="Cut" />
            <telerik:EditorTool Name="Copy" />
            <telerik:EditorTool Name="Paste" />
            <telerik:EditorTool Name="PasteFromWord" />
            <telerik:EditorTool Name="PastePlainText" />
            <telerik:EditorTool Name="PasteAsHtml" />
        </telerik:EditorContextMenu>
        <telerik:EditorContextMenu TagName="A" Enabled="false">
            <telerik:EditorTool Name="SetLinkProperties" />
            <telerik:EditorTool Name="Unlink" />
        </telerik:EditorContextMenu>
        <telerik:EditorContextMenu TagName="IMG" Enabled="true">
            <telerik:EditorTool Name="SetImageProperties" />
            <telerik:EditorTool Name="ImageMapDialog" />
        </telerik:EditorContextMenu>
        <telerik:EditorContextMenu TagName="TABLE">
            <telerik:EditorTool Name="ToggleTableBorder" />
            <telerik:EditorTool Name="SetTableProperties" />
            <telerik:EditorTool Name="DeleteTable" />
        </telerik:EditorContextMenu>
        <telerik:EditorContextMenu TagName="TD">
            <telerik:EditorTool Name="InsertRowAbove" />
            <telerik:EditorTool Name="InsertRowBelow" />
            <telerik:EditorTool Name="DeleteRow" />
            <telerik:EditorTool Name="InsertColumnLeft" />
            <telerik:EditorTool Name="InsertColumnRight" />
            <telerik:EditorTool Name="MergeColumns" />
            <telerik:EditorTool Name="MergeRows" />
            <telerik:EditorTool Name="SplitCell" />
            <telerik:EditorTool Name="DeleteCell" />
            <telerik:EditorTool Name="SetCellProperties" />
        </telerik:EditorContextMenu>
        <telerik:EditorContextMenu TagName="P">
            <telerik:EditorTool Name="JustifyLeft" />
            <telerik:EditorTool Name="JustifyCenter" />
            <telerik:EditorTool Name="JustifyRight" />
            <telerik:EditorTool Name="JustifyFull" />
        </telerik:EditorContextMenu>
    </ContextMenus>
....

Тhis can be also configured from the code-behind and in a theme/skin file for multiple editors, or in a toolsfile.XML file.

Try to appl the context menu for the *, p and HTML tags:

MyRadEditor.EnsureToolsFileLoaded();
var contextMenu = MyRadEditor.ContextMenus.FindByTagName("p");
var editorTool = new EditorTool("Toolname");
editorTool.ShowIcon = false;
contextMenu.Tools.Add(editorTool);

 

Best Regards, 
Rumen
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic. 
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Editor
Asked by
Alien Interactive AB
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or