Subscribe to mouse events on Decorations


#1

Does atom provides an API where we can add text decorations and listen to mouse events on them.

I found Atom-IDE-Flow and Atom-Lint doing something similar, but their approach didn’t work for me.

I have about 500 errors each for a text decoration, How can I gracefully show the user each error upon hovering the decoration.

/cc @kevinsawicki @benogle @joefitzgerald @nathansobo


#2

What kind of decorations are you talking about, highlights or overlays? For overlays, it should just be a matter of adding a click handler to the view associated with the item that you add as the overlay. For highlights, it’s probably not possible or at least pretty complicated because they sit underneath the text. We would need to add a feature to the highlight decorations API which we won’t have time to implement for a while.


#3

@nathansobo You are awesome!
Until Atom provides this feature for highlight decoration API, I’ll be doing this

editor = atom.workspace.getActiveEditor()
editorView = atom.workspaceView.getActiveView()
editorView.on 'click.atom-hack',(e)=>
  console.log editor.getCursorBufferPosition()
  // Here I can show the tooltip if there's an error near the position

Position of mouse click?