Select to view content in your preferred language

Is there a way to distinguish a 'normal' Sketch update event from one emitted because of duplication

1554
0
12-23-2023 07:25 AM
tlepel
by
New Contributor

I'm working on an implementation where a graphicsLayer can be edited using a Sketch widget. I ran into some issues when enabling the duplicate button, since my implementation relies on the sketch events

sketch.on('update', ...)

 Now, when enabling the duplicate button, those events are indistinguishable from the events that would be called when aborting an update for a graphic and starting the update again.

{ // Event 1 emitted after duplicating
"graphics": [ ... my graphics ...],
"state": "complete",
"aborted": true,
"tool": "transform",
"toolEventInfo": null,
"type": "update"
},
{ // Event 2 emitted after duplicating
"graphics": [... the new graphics with same attributes and geometry ...],
"state": "start",
"aborted": false,
"tool": "transform",
"toolEventInfo": null,
"type": "update"
}

Does anyone have a suggestion for how to properly handle the duplicate action? I would've expected something like 'tool': 'duplicate' or 'type': 'create' event instead.

0 Replies