Context menu items per marker type


#1

Hi is it possible to structure my menu cson in a way that would make it so the context menu had items when markers are right clicked? For instance, if I right clicked a line that was marked by my package, I would want a certain menu item to be present.

I know you can specify a class in the context menu cson, but are line marker classes not traversed? Is there an easy way to do what I want to do, or will I need to do something more involved? Thanks!


#2

Alright I’ve looked into this a little more. I am now trying to listen for a mousedown on the text editor and then I will figure out if it is over one of my markers. However, I’ve noticed mousedown fires after the context menu is already opened…

atom.views.getView(atom.workspace.getActiveTextEditor()).addEventListener 'mousedown', (e) =>
   console.log(e)

Am I doing something wrong or is the mousedown really supposed to fire after the context menu opens? (Same thing happens for listening for contextmenu event :frowning:


#3

It sounds like you’re adding a listener that gets fired after the one the system added. I suspect they’re being fired in the order in which they were queued?


#4

Yes, that’s probably it. I don’t suppose there’s a way to move mine up in the event queue? Or somehow intercept/override some core atom code?

Right now, the only way I can think to achieve dynamic context menus for markers is to rebuild the menu on every line mouseover… I can’t seem to find any examples of it being done, so I’m not even sure if it’s possible to do it a more efficient way than that.