<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Cancel Sketch Update in JS API 4 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400518#M36890</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd suggest adding attributes to your graphics to determine which graphics can be updated or which ones are not allowed to be updated. Then in the sketch's update event, check the selected graphic's attributes to see if the update is allowed. If not then call cancel. &lt;A href="https://codepen.io/U_B_U/pen/OJLWNWq?editors=1000"&gt;This test app&lt;/A&gt;&amp;nbsp;should show the general concept.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Aug 2019 15:59:16 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2019-08-22T15:59:16Z</dc:date>
    <item>
      <title>Cancel Sketch Update in JS API 4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400515#M36887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to cancel a sketch during an update. I want to cancel update operation based on a condition.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;const sketch = new Sketch({&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;layer: layer,&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;view: view&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sketch.on('update', event =&amp;gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// if something&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; sketch.cancel();&lt;BR /&gt; })&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a CodePen of what i'm trying to achieve.&amp;nbsp;&lt;A href="https://codepen.io/jeromecauchon/pen/ZEzBMBd?&amp;amp;editable=true&amp;amp;editors=100"&gt;Cancel Sketch Update&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2019 20:52:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400515#M36887</guid>
      <dc:creator>JeromeCauchon</dc:creator>
      <dc:date>2019-08-21T20:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel Sketch Update in JS API 4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400516#M36888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think I understand the question. It seems that the codepen does exactly what your post is asking for; it cancels the sketch when the user attempts to update (reshape) the sketch.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Aug 2019 21:02:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400516#M36888</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2019-08-21T21:02:41Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel Sketch Update in JS API 4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400517#M36889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some&amp;nbsp;graphics on my layer that i don't want to be editable. So when i click on one of them, i want to escape the sketch mode. Is it more clear?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2019 11:43:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400517#M36889</guid>
      <dc:creator>JeromeCauchon</dc:creator>
      <dc:date>2019-08-22T11:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel Sketch Update in JS API 4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400518#M36890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd suggest adding attributes to your graphics to determine which graphics can be updated or which ones are not allowed to be updated. Then in the sketch's update event, check the selected graphic's attributes to see if the update is allowed. If not then call cancel. &lt;A href="https://codepen.io/U_B_U/pen/OJLWNWq?editors=1000"&gt;This test app&lt;/A&gt;&amp;nbsp;should show the general concept.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Aug 2019 15:59:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400518#M36890</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2019-08-22T15:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel Sketch Update in JS API 4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400519#M36891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Undral. I tried your test app but even if you cancel the sketch, the sketch box remains on the layer. I tried the reset function too and i have the same behavior.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2019 18:18:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400519#M36891</guid>
      <dc:creator>JeromeCauchon</dc:creator>
      <dc:date>2019-08-23T18:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel Sketch Update in JS API 4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400520#M36892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So there is a timing issue with sketch update event. We will work on this for 4.13. In meantime, you can wrap the sketch.cancel in setTimeout function. You will see the graphic being selected before it is unselected.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;setTimeout(function() {&lt;BR /&gt;&amp;nbsp; sketch.cancel();&lt;BR /&gt; },100);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the approach above does not work then you can set SketchViewModel's &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#updateOnGraphicClick"&gt;updateOnGraphicClick&lt;/A&gt; property false, then add your own hittest logic for updating graphics. &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=sketch-update-validation"&gt;This sample&lt;/A&gt;&amp;nbsp;shows how to use custom hittest logic for updating graphics.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2019 19:29:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400520#M36892</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2019-08-23T19:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: Cancel Sketch Update in JS API 4</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400521#M36893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tanks Undral.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2019 11:18:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/cancel-sketch-update-in-js-api-4/m-p/400521#M36893</guid>
      <dc:creator>JeromeCauchon</dc:creator>
      <dc:date>2019-08-26T11:18:53Z</dc:date>
    </item>
  </channel>
</rss>

