Search code examples
javascriptmouseeventdom-eventsmathjaxright-click

How to prevent MathJax rendered elements from stealing right click events?


I am trying to use MathJax together with the JavaScript InfoVis Toolkit (https://philogb.github.io/jit/; here is a test of how it looks like: https://photon89.gitlab.io/tpiq-experimental/web/new_design_index.html#test.pdf&TEST2&treeView) and struggle with the following problem:

I am using the right click on a node to delete this node. However, if there is some math in the node, the right click is stolen by MathJax. If I click on the math expression itself, it opens a context menu (which can be deactivated via MathJax config). If I click slightly below or above the math expression, however, there is no context menu but the right click event doesn't fire nevertheless and gives an error in the JS console.

I would like to prevent MathJax from stealing the event altogether, the same way it works for the left click but so far I couldn't find a way to do so.


Solution

  • You can prevent MathJax from trapping the contextual menu events by using

    MathJax.Hub.Config({
      menuSettings: {
        context: "Browser"
      }
    });