FreeTextBox

The no. 1 free ASP.NET HTML Editor.
Welcome to FreeTextBox Sign in | Join | Help
in Search

How to Disable rightmouse paste

Last post 03-02-2010, 9:03 AM by samsta101. 8 replies.
Sort Posts: Previous Next
  •  06-16-2006, 3:49 PM 6744

    How to Disable rightmouse paste

     I like to disable the right mouse click inside the Freetextbox.

    I set the pastemode = "Text" , but when user use rightclick and paste, it paste every thing. ( Bug!!!!)

    I like to paste text only to prevent user to paste picture or other things.

    Any other solution??

    Please help!!

  •  06-17-2006, 5:05 PM 6754 in reply to 6744

    Re: How to Disable rightmouse paste

    Bump!!
  •  10-08-2007, 11:48 AM 8594 in reply to 6754

    Re: How to Disable rightmouse paste

    BUMP!!  This is still a bug!
  •  10-17-2007, 6:26 AM 8621 in reply to 8594

    Re: How to Disable rightmouse paste

    Both Ctrl-V and the Paste toolbar button respect the PasteMode setting, but the IE context menu (right-click) does not.  After many fruitless attempts I have finally got the right mouse button disabled to stop people pasting in text from Word and bypassing PasteMode=Text. 

    The way I have done it, you need to edit the javascript of the control so make sure JavaScriptLocation = ExternalFile and SupportFolder is set to the location of your javascript files.

    Edit FTB-FreeTextBox.js, function FTB_FreeTextBox is the first one in there.

    Scan down to where it says,

    if (FTB_Browser.isIE) {

    this.designEditor.document.execCommand("2D-Position", true, true);

    this.designEditor.document.execCommand("MultipleSelection", true, true);

    }

    and add my line at the bottom of the IF code,

    if (FTB_Browser.isIE) {

    this.designEditor.document.execCommand("2D-Position", true, true);

    this.designEditor.document.execCommand("MultipleSelection", true, true);

    //Added by D Torrens

    //Disable right-click in the editor to prevent pasting from the right-click menu

    this.designEditor.document.oncontextmenu = function(){return false;};

    }

     

    Right click is now disabled within the design view of the control.

  •  10-19-2007, 11:30 AM 8634 in reply to 8621

    Re: How to Disable rightmouse paste

    Found another loophole in the pasting code.  The Shift-Insert shortcut was being used by people to paste text into our control.  This key combination was not handled by FTB and allowed pasting from Word with all the formatting that comes with it.

    Had to edit FTB-FreeTextBox.js again (new code highlighted in bold below),

    } else if ((ev.ctrlKey && !ev.shiftKey && !ev.altKey)) {

    if (ev.keyCode == FTB_KEY_V || ev.keyCode == 118) {

    this.CapturePaste();

    this.CancelEvent(ev);

    }

    } else if ((ev.shiftKey && !ev.ctrlKey && !ev.altKey)) {

    if (ev.keyCode == 45 && ev.type == "keydown") {

    //Capture Shift-Insert as another way of pasting

    this.CapturePaste();

    this.CancelEvent(ev);

    }

  •  03-06-2008, 8:16 AM 8948 in reply to 8634

    Re: How to Disable rightmouse paste

    Hello

    When you don't have the license, how can you do??

    Thank you

    Stéphane

  •  03-10-2008, 9:48 AM 8957 in reply to 8948

    Re: How to Disable rightmouse paste

    You don't need the licence to be able to do this.  The javascript is part of the download.  You just have to setup the control to use your javascript as described in earlier post.
  •  03-02-2009, 4:53 PM 9762 in reply to 8957

    Re: How to Disable rightmouse paste

    It should be noted that the user can drag from Word into the FreeTextBox and bypass the filtering code. Not sure how one would fix that.
  •  03-02-2010, 9:03 AM 10370 in reply to 8621

    Re: How to Disable rightmouse paste

    This isn't working for me. Tried in FireFox and IE 6... Right-click still enabled.

    Any ideas?

     

View as RSS news feed in XML
www.freetextbox.com