<?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 How to turn tool for mapclick event on and off in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861714#M11837</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When my custom widget opens, I have a map onclick event enabled that&amp;nbsp;turns on with no problem from a toggle button. The user then clicks on the map and gets some info based on the click. But I can't turn the functionality off again. When the button is toggled off the mapclick still works. Even after the widget container is closed, the mapclick event is still active.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried using a handle with dojo.connect and dojo.disconnect but that hasn't worked for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basic widget stuff but I'm not getting it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2018 17:05:30 GMT</pubDate>
    <dc:creator>ElizabethMiller</dc:creator>
    <dc:date>2018-05-11T17:05:30Z</dc:date>
    <item>
      <title>How to turn tool for mapclick event on and off</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861714#M11837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When my custom widget opens, I have a map onclick event enabled that&amp;nbsp;turns on with no problem from a toggle button. The user then clicks on the map and gets some info based on the click. But I can't turn the functionality off again. When the button is toggled off the mapclick still works. Even after the widget container is closed, the mapclick event is still active.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried using a handle with dojo.connect and dojo.disconnect but that hasn't worked for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basic widget stuff but I'm not getting it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2018 17:05:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861714#M11837</guid>
      <dc:creator>ElizabethMiller</dc:creator>
      <dc:date>2018-05-11T17:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to turn tool for mapclick event on and off</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861715#M11838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Elizabeth,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;To start you should not use dojo.connect it replaced by dojo on.&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;P&gt;As of Dojo 1.7, the preferred way of handling events is to use the new lightweight&amp;nbsp;&lt;A href="https://dojotoolkit.org/reference-guide/1.8/dojo/on.html#dojo-on" rel="nofollow noopener noreferrer" target="_blank"&gt;dojo/on&lt;/A&gt;&amp;nbsp;module.&lt;/P&gt;&lt;P&gt;For compatibility reasons, the dojo.connect api’s will remain fully supported through remaining 1.x releases, but will likely be removed in Dojo 2.0. Migration from connect() to on() should be straightforward as the api signature is very similar.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;If you create a handle in your widget for the map on click event you can remove the event listener by using mapClickEvt.remove() on widget close and or deactive.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The proper way to do this in code is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;own&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapClickEvtHandler &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;on&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'click'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; lang&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;hitch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;//your function code&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

onClose&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;this&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapClickEvtHandler&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;remove&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:41:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861715#M11838</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T10:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to turn tool for mapclick event on and off</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861716#M11839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Once again you have helped me with exactly what I needed. Thank you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where should I have looked for documentation or examples of this that I could have found on my own?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2018 18:07:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861716#M11839</guid>
      <dc:creator>ElizabethMiller</dc:creator>
      <dc:date>2018-05-11T18:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to turn tool for mapclick event on and off</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861717#M11840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Various Dojo documentation as this involves several classes, but mainly &lt;A class="link-titled" href="https://dojotoolkit.org/reference-guide/1.10/dojo/on.html#removing-an-event-handler" title="https://dojotoolkit.org/reference-guide/1.10/dojo/on.html#removing-an-event-handler"&gt;dojo/on — The Dojo Toolkit - Reference Guide&lt;/A&gt;&amp;nbsp;. But looking at esri OTB widget is great place too. You will see that they use this.own all throughout their widget an only use dojo on.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2018 18:12:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-turn-tool-for-mapclick-event-on-and-off/m-p/861717#M11840</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2018-05-11T18:12:25Z</dc:date>
    </item>
  </channel>
</rss>

