Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hello all!
I am working on customising our Arbortext context menu.
I want to indicate on the menu which tabstyle is set to the table.
For that I am trying to add a listener for the Event Types MenuPost
But I can only find examples of adding event listeners on the document, not on the window (Which is the domain of the menuEvents to the best of my understanding)
Here is the JavaScript code I use:
function menuPost(event) { var node = event.target; var context = ""; while (node != null) { if (node.nodeType == node.ELEMENT_NODE) { context = "(" + node.nodeName + context; } node = node.parentNode; } Application.print(context + "\n"); event.stopPropagation(); } function clickEvent(event) { var node = event.target; var context = ""; while (node != null) { if (node.nodeType == node.ELEMENT_NODE) { context = "(" + node.nodeName + context; } node = node.parentNode; } Application.print(context + "\n"); event.stopPropagation(); } var doc = Application.activeDocument; // define an object with the required handleEvent method var o = { handleEvent: clickEvent }; var listener = Packages.org.w3c.dom.events.EventListener(o); doc.addEventListener("click", listener, true); var o2 = { handleEvent: menuPost }; var listener2 = Packages.org.w3c.dom.events.EventListener(o2); doc.addEventListener("MenuPost", listener2, true);
The mouse click works, but the MenuPost doesn't.
Any idea how I should go about that?
10x!