Click to clear marker created with cm.addWidget()

I would like to clear the marker created with cm.addWidget() when it’s clicked. The widget (DOM element) created with cm.addWidget() function appears to be not receiving the click event.

Any way to get around this?

That was a bug, which should be addressed by this patch.

Is there any reason you want to add the node to the inside of the editor? I’m thinking of deprecating addWidget, since it is usually better to overlay nodes on the editor from outside, but I’m interested in use cases that might make me reconsider.

My use case for addWidget is to add space below a line so that it can line up with something else. I’m using it in http://diff.so to create a side-by-side diff. So, if you type:

a   |    a
b   |    
c   |    c

The space below the a on the right is a widget.

I’m open to ideas on a better way to do this - it’s definitely a bit of a hack.

My use case is to flag certain part of the source code being edited to indicate error location, error text or just a visual marker for easy locating them. But I am open to other ways to do the same.

I assume you’re using addLineWidget, not addWidget, then. Also, look at the connect: "align" option that recently was added to the merge addon. It does precisely this.

What visual style are you going for? markText might be easier to work with.

MarkText only sets visual effect via class. Though that may fit some of the needs but I also need to add some text besides visual effect. It appears setBookmark is a better fit for my needs, but I am not sure if it supports click event.

Widgets added with setBookmark do support click events, yes.

You’re exactly right - I didn’t have the code open in front of me and forgot. Thanks for the pointer - embarrassingly, I had no idea this existed.