<?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 Adding a Custom Button in Sketch Widget Toolbar in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-custom-button-in-sketch-widget-toolbar/m-p/1220626#M78948</link>
    <description>&lt;P&gt;I want to add my own button into the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html" target="_self"&gt;sketch widget toolbar.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/custom-buttons/td-p/19996" target="_self"&gt;This forum post&lt;/A&gt; will create the button in a new div outside of the Sketch Widget.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaulAnderson2k_0-1665486049663.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/53309iF004BC0B03FB0150/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaulAnderson2k_0-1665486049663.png" alt="PaulAnderson2k_0-1665486049663.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With the code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.when(() =&amp;gt; {
    const sketch = new Sketch({
      layer: graphicsLayer,
      view: view,
      // graphic will be selected as soon as it is created
      creationMode: "update"
    });

    view.ui.add(sketch, "top-right");

    var element = document.createElement('div');
    element.className = "esri-icon-collection esri-widget--button esri-widget esri-interactive";
    element.addEventListener('click', function (evt) {
      console.log("clicked");
    })

    view.ui.add(element, "top-right");

  });&lt;/LI-CODE&gt;&lt;P&gt;I'd really want to include that button alongside all of the other buttons - and still &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html#availableCreateTools" target="_self"&gt;control what tools are available&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Is there a recommended ways to do this? Are there any articles?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Oct 2022 11:05:39 GMT</pubDate>
    <dc:creator>PaulAnderson2k</dc:creator>
    <dc:date>2022-10-11T11:05:39Z</dc:date>
    <item>
      <title>Adding a Custom Button in Sketch Widget Toolbar</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-custom-button-in-sketch-widget-toolbar/m-p/1220626#M78948</link>
      <description>&lt;P&gt;I want to add my own button into the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html" target="_self"&gt;sketch widget toolbar.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/custom-buttons/td-p/19996" target="_self"&gt;This forum post&lt;/A&gt; will create the button in a new div outside of the Sketch Widget.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaulAnderson2k_0-1665486049663.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/53309iF004BC0B03FB0150/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaulAnderson2k_0-1665486049663.png" alt="PaulAnderson2k_0-1665486049663.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With the code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.when(() =&amp;gt; {
    const sketch = new Sketch({
      layer: graphicsLayer,
      view: view,
      // graphic will be selected as soon as it is created
      creationMode: "update"
    });

    view.ui.add(sketch, "top-right");

    var element = document.createElement('div');
    element.className = "esri-icon-collection esri-widget--button esri-widget esri-interactive";
    element.addEventListener('click', function (evt) {
      console.log("clicked");
    })

    view.ui.add(element, "top-right");

  });&lt;/LI-CODE&gt;&lt;P&gt;I'd really want to include that button alongside all of the other buttons - and still &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html#availableCreateTools" target="_self"&gt;control what tools are available&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Is there a recommended ways to do this? Are there any articles?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 11:05:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-custom-button-in-sketch-widget-toolbar/m-p/1220626#M78948</guid>
      <dc:creator>PaulAnderson2k</dc:creator>
      <dc:date>2022-10-11T11:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a Custom Button in Sketch Widget Toolbar</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-custom-button-in-sketch-widget-toolbar/m-p/1220719#M78957</link>
      <description>&lt;P&gt;The widget isn't extensible, so you can't add more buttons. You can use the SketchViewModel and build a custom component around that.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Depending what you want it to do though, you could have a container that wraps the Sketch widget and your custom button along side each other, so it &lt;EM&gt;looks&lt;/EM&gt; like a new button, but when you click it, you can call methods on the Sketch widget or the layer, not sure what your button would do.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 14:31:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-a-custom-button-in-sketch-widget-toolbar/m-p/1220719#M78957</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-10-11T14:31:19Z</dc:date>
    </item>
  </channel>
</rss>

