Prevent right-click context menu in View


I’m working on a 3D package for Atom. The user can left-click to rotate, scroll to zoom, and right-click to pan. The only problem is that the context menu pops up every time I try to pan, with the “Reveal in tree view” option. I’d like to prevent the mousedown event from being seen by the method that handles the context menu so that the pan behavior can continue uninterrupted.

Disable right click menu on preview window (Javascript)

Have you tried stopping the propagation of the event?


The normal way to do it should work:

{$} = require 'atom'

$(elem).on 'contextmenu', -> false


Thanks, that worked! I’m still getting used to space-pen, so I appreciate the help.


Also if you’re doing it in a space-pen view, you can skip creating the jQuery object (as it already is one):

@on 'contextmenu', -> false


A fun factoid: JQuery supports false without a function to do the same thing. I don’t know if space-pen does.

$(elem).on 'contextmenu', false