<?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: Disable unselection in sketchviewmodel in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510596#M47548</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;That is because, the sample is calling sketchViewModel.update method if user clicks outside of the graphic. You can just return when this happens that way you will not use your undo/redo stack. Calling sketchViewMode.update resets the undo/redo stack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;event&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;state &lt;SPAN class="operator token"&gt;===&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"cancel"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt; event&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;state &lt;SPAN class="operator token"&gt;===&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"complete"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;!&lt;/SPAN&gt;contains &lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt; intersects&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
   &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="comment token"&gt;// sketchViewModel.update([graphic], { tool: "reshape" });&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:21:39 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2021-12-11T22:21:39Z</dc:date>
    <item>
      <title>Disable unselection in sketchviewmodel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510593#M47545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using sketchviewmodel to build a custom editing experience.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my application I want to force the user to only update a single graphic. It should not be possible to click outside the graphic to cancel/complete the update operation. Unfortunately I cannot seem to disable the behaviour where a graphic is unselected when the user clicks outside the graphic. I've tried listening to the click event on the mapview and calling stopPropagation, but that doesn't seem to have an effect as the graphic is still unselected when I click outside it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know a way to disable the cancel/complete events that fires when clicking outside a graphic that is being updated using the sketchviewmodel?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Dec 2019 15:00:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510593#M47545</guid>
      <dc:creator>ae</dc:creator>
      <dc:date>2019-12-06T15:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: Disable unselection in sketchviewmodel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510594#M47546</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does something like this help?&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/sample-code/sketch-update-validation/index.html" title="https://developers.arcgis.com/javascript/latest/sample-code/sketch-update-validation/index.html"&gt;Sketch update validation | ArcGIS API for JavaScript 4.13&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It limits the actions and extent of updates using the SketchViewModel.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Dec 2019 21:11:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510594#M47546</guid>
      <dc:creator>Noah-Sager</dc:creator>
      <dc:date>2019-12-06T21:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Disable unselection in sketchviewmodel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510595#M47547</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks for the reply. That helps as I am able to re-trigger the update operation if the user clicks outside the feature. However, the undo/redo stack is lost when this happens, which is a pity.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2019 09:24:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510595#M47547</guid>
      <dc:creator>ae</dc:creator>
      <dc:date>2019-12-09T09:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Disable unselection in sketchviewmodel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510596#M47548</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;That is because, the sample is calling sketchViewModel.update method if user clicks outside of the graphic. You can just return when this happens that way you will not use your undo/redo stack. Calling sketchViewMode.update resets the undo/redo stack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;event&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;state &lt;SPAN class="operator token"&gt;===&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"cancel"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt; event&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;state &lt;SPAN class="operator token"&gt;===&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"complete"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;!&lt;/SPAN&gt;contains &lt;SPAN class="operator token"&gt;||&lt;/SPAN&gt; intersects&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
   &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
   &lt;SPAN class="comment token"&gt;// sketchViewModel.update([graphic], { tool: "reshape" });&lt;/SPAN&gt;
 &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:21:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510596#M47548</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2021-12-11T22:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Disable unselection in sketchviewmodel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510597#M47549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried your&amp;nbsp;suggestion Undral but I cannot get it to work. If I edit the example to just return:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;else if (event.state === "cancel" || event.state === "complete") {
    if (!contains || intersects) {
       return;
    }‍‍‍‍
}&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then click outside the graphic that is being updated, the graphic looses its editing focus and the undo/redo stack is lost. What I want to achieve is to keep the editing focus on the graphic despite clicking outside the graphic, and at the same time keep the undo/redo stack.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps I'm missing something. It would be great if you could provide a small example.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:21:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510597#M47549</guid>
      <dc:creator>ae</dc:creator>
      <dc:date>2021-12-11T22:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Disable unselection in sketchviewmodel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510598#M47550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;public startEdit() {
    this.history = null;
 &amp;nbsp;&amp;nbsp;&amp;nbsp;this.updateHandle = this.sketchViewModel.on('update', this.onGraphicUpdate.bind(this));
}

private onGraphicUpdate(event) {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;const graphic: __esri.Graphic = event.graphics[0];

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (event.state === 'complete' || event.state === 'cancel') {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this.sketchViewModel.update([graphic], {
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;tool: 'reshape',
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return;
 &amp;nbsp;&amp;nbsp;&amp;nbsp;}
 }&lt;/PRE&gt;&lt;P&gt;This should work (notice that this is Typescript).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to take the undo stack to the newly started update session you have to do some hacking on the sketchViewModel and save the history (not recommended):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;public startEdit() {&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp; &amp;nbsp; this.updateHandle = this.sketchViewModel.on('update', this.onGraphicUpdate.bind(this));&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;}&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;

&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;private onGraphicUpdate(event) {&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; const graphic: __esri.Graphic = event.graphics[0];&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;

&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (event.state === 'complete') {&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;    this.sketchViewModel.update([graphic], {&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;    tool: 'reshape',&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  });&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;

&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  if (this.history &amp;amp;&amp;amp; (this.sketchViewModel as any)._operationHandle) {&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(this.sketchViewModel as any)._operationHandle.history = this.history;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  }&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;  return;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'andale mono', monospace;"&gt;    }

    this.history = (this.sketchViewModel as any)._operationHandle.history;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
}
&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;
 (hope Esri will support this in a future release):&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:33:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510598#M47550</guid>
      <dc:creator>FreddyBroring</dc:creator>
      <dc:date>2021-12-12T16:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Disable unselection in sketchviewmodel</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510599#M47551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks for the example Freddy. I will re-trigger&amp;nbsp;update&amp;nbsp;as you suggest and skip hacking the sketchviewmodel in case it has some unwanted side-effects. I too hope esri will add this functionality.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Dec 2019 14:08:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-unselection-in-sketchviewmodel/m-p/510599#M47551</guid>
      <dc:creator>ae</dc:creator>
      <dc:date>2019-12-10T14:08:17Z</dc:date>
    </item>
  </channel>
</rss>

