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

[Solved] Custom Context Menus

2 Answers 171 Views
Editor
This is a migrated thread and some comments may be shown as answers.
safeer ahmad
Top achievements
Rank 1
safeer ahmad asked on 16 Oct 2009, 04:12 PM
Hi,
I am using rad editor to manipulate some content. The content is like that..
This is& some sample$ content This is some£ sample content
Notice these &,$ symbols here...when user selects any of these symbols and press right click I need to show a 
context menu saying REMOVE SYMBOL.... right now according to my understandings you have to relate context menus with a tag....which I don't have here....in fact I want to show the context menu on the basis of some condition.

Any help????

Thanks




2 Answers, 1 is accepted

Sort by
0
safeer ahmad
Top achievements
Rank 1
answered on 19 Oct 2009, 09:55 AM
any help?????
0
Rumen
Telerik team
answered on 21 Oct 2009, 05:43 PM
Hi Safeer,

You can create your own custom context menu using the oncontextmenu event of RadEditor:

<script type="text/javascript">  
function CallContextMenu(editor)   
{   
    editor.attachEventHandler ("oncontextmenu"function (e)   
    {     
        var oSelection = editor.getSelectedElement();  
        if(oSelection.tagName == "IMG"
        { 
            if (oSelection.getAttribute("custom") == "custom"
            { 
                alert("the selected element className is " + oSelection.className); 
                alert("the 'e' argument returns the mouse position " + e);  
                alert("get a reference to the editor's body " + editor.get_document().body);  
                alert("the selected element is " + oSelection.tagName);  
                $telerik.cancelRawEvent(e);  
                return false//disable the browser's context menu     
            } 
        } 
    });  
}   
</script>  
  
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="CallContextMenu">  
  <Content> 
    <img src="test.jpg" custom="custom" class=".customImage"/> 
  </Content> 
</telerik:RadEditor> 

See this article to learn how to get the text of the current selection
http://www.telerik.com/help/aspnet-ajax/editor_gettext2.html

Please, note that this functionality is not offered out-of-the box by RadEditor and we do not support it.

All the best,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Editor
Asked by
safeer ahmad
Top achievements
Rank 1
Answers by
safeer ahmad
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or