How to add a button to the ribbon on an existing tab

2903
8
Jump to solution
03-12-2021 07:42 AM
BerendVeldkamp
Occasional Contributor II

in ArcGIS Pro, is it possible to add a button to an existing tab on the ribbon? I'd like to have my button appear on the Insert tab rather than the default Add-In tab.

 

I tried to add it to esri_mapping_insertTab, but that doesn't seem to work.

<tabs>
    <tab id="esri_mapping_insertTab">
        <group refID="My_Group1" />
    </tab>
</tabs>

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

You can lookup the existing DAML ids in this reference: ArcGIS Pro DAML ID Reference  You can also look at the Pro DAML directly by using the ".daml file" links in this reference.   The following document has more information on DAML: Introduction to DAML (Desktop Application Markup Language)  in addition to the help already mentioned above.

And here is an example that inserts a group with your new button in the 'Insert' tab on the ribbon:

<ArcGIS defaultAssembly="UpdateInsertTab.dll" defaultNamespace="UpdateInsertTab" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
  <AddInInfo id="{4fd9b454-7bce-426f-8bfe-9833c882f99d}" version="1.0" desktopVersion="2.7.26828">
    <Name>UpdateInsertTab</Name>
    <Description>UpdateInsertTab description</Description>
    <Image>Images\AddinDesktop32.png</Image>
    <Author>wlfka</Author>
    <Company>Acme</Company>
    <Date>3/12/2021 7:42:07 AM</Date>
    <Subject>Framework</Subject>
  </AddInInfo>
  <modules>
    <insertModule id="UpdateInsertTab_Module" className="Module1" autoLoad="false" caption="Module1">
      <groups>
        <group id="UpdateInsertTab_Group1" caption="Group 1" appearsOnAddInTab="false">
          <button refID="UpdateInsertTab_InsertTabButton" size="large" />
        </group>
      </groups>
      <controls>
        <!-- add your controls here -->
        <button id="UpdateInsertTab_InsertTabButton" caption="InsertTabButton"
								className="InsertTabButton" loadOnClick="true" 
								smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" 
								largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png">
          <tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip>
        </button>
      </controls>
    </insertModule>
		<updateModule refID="esri_core_module">
			<tabs>
		    <updateTab refID="esri_core_insertTab" >
					<insertGroup refID="UpdateInsertTab_Group1" placeWith="esri_project_styles" insert="before"/>				
			  </updateTab>
			</tabs>
		</updateModule>
  </modules>
</ArcGIS>

this looks like this:

Wolf_0-1615572075508.png

 

View solution in original post

8 Replies
KenBuja
MVP Esteemed Contributor

Which module are you putting this in? You have to use the UpdateModule to make modifications to an existing group. From the help, this is how to remove a button from a group

 

<updateModule refID="esrimappingExtension">
   <groups>
      <updateGroup refID="ESRImappingFindGroup">
         <deleteButton refID="ESRImappingFindButton"/>
      </updateGroup>
   </groups>
</updateModule>

 

 

0 Kudos
BerendVeldkamp
Occasional Contributor II

Thanks, I didn't know the updateModule tag.

 

However, I can't seem to actually add a button. This is what I have now:

<updateModule refID="esrimappingExtension">
  <groups>
    <insertGroup id="My_Group1" caption="Hello" appearsOnAddInTab="false">
      <button refID="My_Button" size="large" />
    </insertGroup>
  </groups>
  <controls>
    <!-- Add button here? -->
  </controls>
</updateModule>

This should at least add an empty group, right?

The controls tag only accepts deleteButton or updateButton, but no button (or insertButton, or whatever).

 

Do you happen to have an example of how to actually add a button? And are the existing refID's documented somewhere?

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

You can lookup the existing DAML ids in this reference: ArcGIS Pro DAML ID Reference  You can also look at the Pro DAML directly by using the ".daml file" links in this reference.   The following document has more information on DAML: Introduction to DAML (Desktop Application Markup Language)  in addition to the help already mentioned above.

And here is an example that inserts a group with your new button in the 'Insert' tab on the ribbon:

<ArcGIS defaultAssembly="UpdateInsertTab.dll" defaultNamespace="UpdateInsertTab" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
  <AddInInfo id="{4fd9b454-7bce-426f-8bfe-9833c882f99d}" version="1.0" desktopVersion="2.7.26828">
    <Name>UpdateInsertTab</Name>
    <Description>UpdateInsertTab description</Description>
    <Image>Images\AddinDesktop32.png</Image>
    <Author>wlfka</Author>
    <Company>Acme</Company>
    <Date>3/12/2021 7:42:07 AM</Date>
    <Subject>Framework</Subject>
  </AddInInfo>
  <modules>
    <insertModule id="UpdateInsertTab_Module" className="Module1" autoLoad="false" caption="Module1">
      <groups>
        <group id="UpdateInsertTab_Group1" caption="Group 1" appearsOnAddInTab="false">
          <button refID="UpdateInsertTab_InsertTabButton" size="large" />
        </group>
      </groups>
      <controls>
        <!-- add your controls here -->
        <button id="UpdateInsertTab_InsertTabButton" caption="InsertTabButton"
								className="InsertTabButton" loadOnClick="true" 
								smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" 
								largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png">
          <tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip>
        </button>
      </controls>
    </insertModule>
		<updateModule refID="esri_core_module">
			<tabs>
		    <updateTab refID="esri_core_insertTab" >
					<insertGroup refID="UpdateInsertTab_Group1" placeWith="esri_project_styles" insert="before"/>				
			  </updateTab>
			</tabs>
		</updateModule>
  </modules>
</ArcGIS>

this looks like this:

Wolf_0-1615572075508.png

 

BerendVeldkamp
Occasional Contributor II

Thanks, that works. Unfortunately not in version 2.5 which is the version I am supposed to be working in ☹️. But in 2.7, yes. (I didn't test 2.6)

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I haven't tried this yet, but any DAML 'dependencies' needed to be specified in earlier versions of Pro.  I think if you specify the 'dependencies' tag in the 2.5 DAML  this should work in 2.5 as well.  You have to add the 'module's DAML filename' that you are 'depending' on like it is shown in the snippet below.  You can find the module's name in the DAML reference documentation .   The dependencies tag is inserted before the modules tag:

<ArcGIS defaultAssembly="CustomCatalogContext.dll" ...>
  <AddInInfo id="... 
  </AddInInfo>
  <dependencies>
    <dependency name="ADCore.daml" />
    <dependency name="ADMapping.daml" />
  </dependencies>
  <modules>

 

0 Kudos
BerendVeldkamp
Occasional Contributor II

That would make sense, but it still doesn't seem to work.

 

I'm only referencing stuff from ADCore, but adding that module as a dependency doesn't change anything. Here's what I have now:

<ArcGIS defaultAssembly="ProAppModule3.dll" defaultNamespace="ProAppModule3" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
  <AddInInfo id="{f2d61d01-095a-4b9a-9bf3-4437643fe624}" version="1.0" desktopVersion="2.5.22081">
    <Name>ProAppModule3</Name>
    <Description>ProAppModule3 description</Description>
    <Image>Images\AddinDesktop32.png</Image>
    <Author>NLBVRE</Author>
    <Company>Acme</Company>
    <Date>3/16/2021 10:34:42 AM, 2021</Date>
    <Subject>Framework</Subject>
    <!-- Note subject can be one or more of these topics:
                    Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration -->
  </AddInInfo>
  <dependencies>
    <dependency name="ADCore.daml" />
  </dependencies>
  <modules>
    <insertModule id="ProAppModule3_Module" className="Module1" autoLoad="false" caption="Module1">
      <groups>
        <group id="UpdateInsertTab_Group1" caption="Group 1" appearsOnAddInTab="false">
          <button refID="ProAppModule3_Button1" size="large" />
        </group>
      </groups>
      <controls>
        <!-- add your controls here -->
        <button id="ProAppModule3_Button1" caption="Button 1" className="Button1" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png">
          <tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip>
        </button>
      </controls>

    </insertModule>

    <updateModule refID="esri_core_module">
      <tabs>
        <updateTab refID="esri_core_insertTab">
          <insertGroup refID="UpdateInsertTab_Group1" placeWith="esri_project_styles" insert="before"/>
        </updateTab>
      </tabs>
    </updateModule>

  </modules>
</ArcGIS>

 

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I tried this using Pro version 2.5 and as you noted above it is a problem.  In 2.5 I can only add a button to an existing group (see below), but i can't add a group to a tab.

Wolf_0-1616104257913.png

<updateModule refID="esri_core_module">
  <groups>
    <updateGroup refID="esri_core_projectData" >
      <insertButton refID="ProAppModule6_Button1" size="large" />
    </updateGroup>
  </groups>
</updateModule>

It seems like the problem has been resolved in later releases.  

BerendVeldkamp
Occasional Contributor II

Thanks, that is good enough for now. My project has only one button, and it doesn't really need a separate group.

Two things to note for whoever wants to do something similar:

  • When looking up the ID of an existing group, make sure you're looking at the correct version of the DAML. Although they are the same for large parts, there are some minor differences. E.g. 2.7 has esri_mapping_layerGroup whereas in 2.5 it's called esri_mapping_mapGroup. If you want to support multiple versions, I suppose two updateGroup tags are needed (but I haven't tried that yet)
  • There is no need to insert dependencies mentioned earlier, it works fine without those
0 Kudos