Hi Michael,
While I do think the solution guus has provided is cleaner, I have tested and expanded my example.
You first need to create a .js file somewhere under webcontent and adapt the source below to your paths:
egl.defineClass('CustomJavascript', 'BrowserFunctions', { "eze$$initializeDOMElement": function(){ }, "constructor": function(){ }, "disableRightClick": function (widget) { widget.eze$$DOMElement.oncontextmenu = function (event){ if (event.button == 2){ alert("Right Click Disabled"); return false; } }; widget.eze$$DOMElement.onclick = function (event){ if (event.button == 2) { alert("Right Click Disabled"); return false; } }; }});
Then you need to create a egl file with the following content (again, adapt to your directory structure)
package com.molcy.egl.ExternalTypes;externalType BrowserFunctions extends Widget type JavaScriptObject { relativePath = "CustomJavascript", javaScriptName = "BrowserFunctions" } function disableRightClick(w Widget in); end
Then use the externaltype in a handler like the following one:
package com.molcy.egl.handlers;import com.ibm.egl.rui.widgets.Box;import com.ibm.egl.rui.widgets.Div;import com.molcy.egl.ExternalTypes.BrowserFunctions;handler DisableRightClick type RUIhandler {initialUI = [ alles ],onConstructionFunction = start, cssFile="css/FileUploadRui.css", title="DisableRightClick"} alles Box{ columns = 2, children= [ div1, div2 ] }; div1 Div{width = 200, height = 200, backgroundcolor = "red"}; div2 Div{width = 200, height = 200, backgroundcolor = "green"}; b BrowserFunctions{}; function start() b.disableRightClick(div1); end end
Kind regards,
Bram
Bram_Callewaert