Prevent right-click context menu in View


#1

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)
#2

Have you tried stopping the propagation of the event?


#3

The normal way to do it should work:

{$} = require 'atom'

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

#4

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


#5

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

#6

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