Disable mouse right-click menu

We have a requirement from our client to disable the mouse right-click context menu. Is there any mechanism in mendix to do the same?
2 answers

No such functionality is delivered out-of-the-box with Mendix. This does not, however, mean that you can't fulfill your client's requirements.

Disabling right-click functionality is done in JavaScript by capturing relevant events (generally on document/window / onmousedown/onmouseup) and not propagating them. If you are using Mendix 2.4 the easiest way to do this is to create a theme package with a modified index page that contains either the JavaScript code to do this or a SCRIPT tag that references a JavaScript source file containing the code.

If you want an example/proof-of-concept I'll write one for you, so let me know here.


To add the JavaScript code for disabling right-click in an application, edit the index3.html file (after testing it you should put this file in a theme package so the modifications carry over to deployment).

In index3.html, inside the HEAD tag, you should see these lines,

<script type="text/javascript" src="mxclientsystem/dijit/dijit.js"></script>
<script type="text/javascript" src="mxclientsystem/mendix/mendix.js"></script>

Right below these lines, add the following code (which I've adapted from other implementations found on the web and tested in IE, Firefox and Chrome),

<script type="text/javascript">

  function disableRightClickIE() {
    if (document.all) {
      return false;

  function filterRightClick(e) {
    if (document.layers||(document.getElementById && !document.all)) {
      if (e.which == 2 || e.which == 3) {
        return false;

  if (document.layers) {
    document.onmousedown = filterRightClick;
  } else {
    document.onmouseup = filterRightClick;
    document.oncontextmenu = disableRightClickIE;

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


This will prevent the right-click event from propagating (if the conditions are met, the handlers return false) and effectively disable right-click.

You can, of course, also put this code in a JavaScript separate file.

Hope this helps.