I am trying to implement an undo/redo functionality during drawing a fetaure using the draw interaction. For the modify interaction I was able to to do it using the 'modifyend'
event. like so:
modifyInteraction.on('modifyend',function(e){
}
while for the draw interaction no such events exist.
'drawend'
event fires when finishing my drawing. But I need to trace all the vertices drawn in the meantime.
For the time being I came up with this:
myapp.Editor.editDraw = new ol.interaction.Draw({
source: myapp.Editor.PseudoEditLyr.getSource(),
type: type,/** @type {ol.geom.GeometryType} */
style: drawStyle,
condition : function(e){
//fires the mousedown event while drawing
console.log("e.browserEvent.type",e.browserEvent.type);
if (myapp.Editor.editSketch ){
myapp.Editor.checkAndPushUndo(myapp.Editor.editSketch);
}
return true;//always return true but need to listen for the mousedown event
}
});
Which does the job but this is not elegant, as it trace the 'mousedown'
event and not the 'vertexadd'
.
Do any of you have any idea?