<?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: How to disable a customer widget? in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766800#M1256</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The code (methods and an attribute to add in the widget) is just fort adding and stopping handlings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After adding this code, you can call addEvent or removeEvent in any other method of the class like onOpen or onClose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the second question, you can watch the code from homeButton widget to see how to do.&lt;/P&gt;&lt;P&gt;It's not exactly what's you want because it use an existing js esri component (HomeButton dijit).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 15 Dec 2014 22:50:39 GMT</pubDate>
    <dc:creator>JeremieCornet1</dc:creator>
    <dc:date>2014-12-15T22:50:39Z</dc:date>
    <item>
      <title>How to disable a customer widget?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766797#M1253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am very new to web application builder, and I am working on building new customer widgets on web application builder.&lt;/P&gt;&lt;P&gt;I have some questions about it, and hope someone could help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. How to disable a customer widget?&lt;/P&gt;&lt;P&gt;For example. I created a widget, after opening it (maybe startup), it will have the function that every time when I click on the map, it will add a new marker on the map point, and center the extent of the map with that marker (the actual widget has more functions than this).&lt;/P&gt;&lt;P&gt;But when I close the widget, I want everything to go back to the default situation, which means do nothing when clicking or dragging the map.&lt;/P&gt;&lt;P&gt;What should I write on the onClose function? destroy the widget?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. How to disable the widget window?&lt;/P&gt;&lt;P&gt;I want to have a widget which only has the icon button to open and close the widget, or even to be invisible. &lt;/P&gt;&lt;P&gt;The problem is that every time when the widget starts up, the blank window shows up (because I don't need any html code).&lt;/P&gt;&lt;P&gt;What can I do to hide the window of the widget?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 08:47:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766797#M1253</guid>
      <dc:creator>LuyiHan</dc:creator>
      <dc:date>2014-12-12T08:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable a customer widget?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766798#M1254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hy Luyi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) you need to use dojo.disconnect. But it requires a reference to the handle.&lt;/P&gt;&lt;P&gt;Add this in your widget :&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;_widgetEvents:[],&lt;/P&gt;&lt;P&gt;addEvent:function(target_object, event_name, slot_function, hitchToThisWidget){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var evt_id = target_object.id + "__" + event_name;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(hitchToThisWidget){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; slot_function = lang.hitch(this, slot_function);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log("-&amp;gt;hitched");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._widgetEvents[evt_id] = this.own(on(this.map, "mouse-move", slot_function));&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;},&lt;/P&gt;&lt;P&gt;removeEvents:function(){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(var evt_id in this._widgetEvents)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.disconnect(this._widgetEvents[evt_id]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete(this._widgetEvents);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this._widgetEvents=[];&lt;/P&gt;&lt;P&gt;},&lt;/P&gt;&lt;P&gt;removeEvent:function(target_object, event_name){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var evt_id = target_object.id + "__" + event_name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.disconnect(this._widgetEvents[evt_id]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete(this._widgetEvents[evt_id]);&lt;/P&gt;&lt;P&gt;},&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And then, in onOpen, add events with this.addEvent&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;this.addEvent(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.map, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'mouse-move', &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; function(evt){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var center = evt.mapPoint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.coordsNode.innerHTML = "X : "+parseInt(center.x).toString()+" ; Y : "+parseInt(center.y).toString();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; true&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And to remove all events in onClose :&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;this.removeEvents();&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or just one event :&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;this.removeEvent(this.map; 'mouse-move');&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) I don't think it's possible to have a widget in icons bar (widgetPool) with an icon and without GUI.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do a &lt;CODE&gt;widgetOnScreen (like coordinate widget) and make a simple GUI (just one button with activated/deactivated status) and capture this button changes to activate/deactivate your even&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 04:10:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766798#M1254</guid>
      <dc:creator>JeremieCornet1</dc:creator>
      <dc:date>2014-12-15T04:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable a customer widget?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766799#M1255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jeremie,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the first question, sorry I don't understand it very well. Does this code only for remove the mouse click event I have defined on the widget or it can "kill" all the functions in the widget and set everthing to default.&lt;/P&gt;&lt;P&gt;Dose the first part of the code shoule be put in the widget.js file?&lt;/P&gt;&lt;P&gt;I tried to follow your suggestion, and it seems doesn't work, maybe there is some part of the code I put it in the wrong place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked the introduction of "dojo.disconnect", it is used to disconnect&amp;nbsp; the previous "dojo.connect" listener, and for me it works, so does this means for every changed made by this widget, I must make sure they have a connect listener, and then create a disconnect event to destroy them?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the second question, I tried to use off panel widget and configure the position of it in the layout of the theme, but it will still open a blank GUI window by itself. Is there some place/code I could define not to show the GUI window or even get the result like you descibed to have &lt;SPAN style="font-family: monospace;"&gt;one button with activated/deactivated status, which is actually what I need for some widgets.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: monospace;"&gt;Thank you very much!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: monospace;"&gt;Luyi&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 10:58:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766799#M1255</guid>
      <dc:creator>LuyiHan</dc:creator>
      <dc:date>2014-12-15T10:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to disable a customer widget?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766800#M1256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The code (methods and an attribute to add in the widget) is just fort adding and stopping handlings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After adding this code, you can call addEvent or removeEvent in any other method of the class like onOpen or onClose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the second question, you can watch the code from homeButton widget to see how to do.&lt;/P&gt;&lt;P&gt;It's not exactly what's you want because it use an existing js esri component (HomeButton dijit).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 22:50:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-disable-a-customer-widget/m-p/766800#M1256</guid>
      <dc:creator>JeremieCornet1</dc:creator>
      <dc:date>2014-12-15T22:50:39Z</dc:date>
    </item>
  </channel>
</rss>

