Leaflet.Editable icon indicating copy to clipboard operation
Leaflet.Editable copied to clipboard

contextmenu event not triggered when continuing polyline

Open opoto opened this issue 7 years ago • 4 comments

When a polyline is being continued, map's "contextmenu" event is not triggered when user right-clicks on the map.

To reproduce:

  1. open https://jsfiddle.net/p3jr7rp8/11/
  2. right click on map: it does not show an alert message, which should be opened by the "contextmenu" listener

if you stop polyline continuation by clicking on last vertex of the line, then right-clicking on the map properly shows the alert window.

opoto avatar Aug 31 '16 22:08 opoto

Leaflet.Editable disable all previous registered events while drawing (and add them back when drawing is finished). It's a bit extreme, but I didn't get to a softer but still robust solution yet. If you want events to be triggered while drawing you need to register them after the drawing has started. See #54 for context. This certainly needs to be documented.

yohanboniface avatar Sep 01 '16 03:09 yohanboniface

Ok, I agree this would need to be documented. In addition I can't make it work: https://jsfiddle.net/p3jr7rp8/13/ Could you provide an example? Thanks

opoto avatar Sep 01 '16 05:09 opoto

Sorry, was in a mission in Jordan, and a bit overwhelmed. So that's not that simple that was I said before: events will only work for element added to the map after the drawing started (so they are active for draw tools). Your best option for now I think is to try to override L.Editable.blockEvents/unblockEvents: https://github.com/Leaflet/Leaflet.Editable/blob/gh-pages/src/Leaflet.Editable.js#L210

But this will suddenly reactivate all others events, so you may have trouble with popups or anything like that during drawing.

Not sure we have a best option, short term speaking.

yohanboniface avatar Sep 07 '16 07:09 yohanboniface

Is there a way to draw a polygon/ any shape using the right mouse click instead of the left mouse click?

tenznhok avatar Jan 26 '18 21:01 tenznhok