I'm trying to cancel a ClickEvent whenever a Polygon is clicked and the Sketch Widget is not expanded.
I've tried the following code.
I think that the problem is that the rest of the ClickEvent does not get cancelled by 'stopPropagation' because it is in a promise.
I've tried coming up with different ways, but I am at a loss here. Any tips would be helpful!
this.mapView.on("immediate-click", (clickEvent: esri.MapViewImmediateClickEvent) => {
console.log("Mapview clicked.");
let sketchExpandWidget: esri.Expand = this.esriWidgetService.getSketchExpandWidget();
this.mapView.hitTest(clickEvent).then((hit: esri.HitTestResult) => {
if (!sketchExpandWidget.expanded) {
//This does not cancel the propagation. Most likely caused by the delay of the callback.
clickEvent.stopPropagation();
}
});
});
.