Select to view content in your preferred language

Delete button from ribbon based on state or condition

1224
4
Jump to solution
07-22-2022 02:23 PM
StephenRhea_NV5
Frequent Contributor

I want to delete a button from the ribbon based on a custom state. I'm already using conditions to enable/disable buttons until the user configures the add-in, but I'm trying to create a "viewer-only" ribbon that doesn't even include buttons for creation/editing. The <updateModule>...<deleteButton> workflow is great, but I only need it to run for a viewer-only build.

My original idea was to check for a compiler directive in the add-in constructor and set a custom "viewer" state, which would then activate the <updateModule> section. Is this possible?

0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

If you create a 'Manage Configuration' instead of an 'Add-in Module' you can customize the User Interface.  See details here: 

ProGuide Configurations · Esri/arcgis-pro-sdk Wiki (github.com)

The ProGuide also references a sample that changes the user interface by removing most ribbons / buttons:

arcgis-pro-sdk-community-samples/Framework/ConfigWithMap at master · Esri/arcgis-pro-sdk-community-s...

and the sample's 'custom' UI looks like this:

Wolf_0-1658812343047.png

An earlier version of the sample checked user permission to determine if the UI was read-only or read/write by controlling the DAML of the 'Start Editing' button, but for simplicity of the sample this feature was removed.

 

View solution in original post

0 Kudos
4 Replies
StephenRhea_NV5
Frequent Contributor

FWIW, another option I'm considering is a separate "viewer-only" daml file that gets swapped out during the build process, but the maintenance risk of the two files getting out of sync is something I'm trying to avoid.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

If you create a 'Manage Configuration' instead of an 'Add-in Module' you can customize the User Interface.  See details here: 

ProGuide Configurations · Esri/arcgis-pro-sdk Wiki (github.com)

The ProGuide also references a sample that changes the user interface by removing most ribbons / buttons:

arcgis-pro-sdk-community-samples/Framework/ConfigWithMap at master · Esri/arcgis-pro-sdk-community-s...

and the sample's 'custom' UI looks like this:

Wolf_0-1658812343047.png

An earlier version of the sample checked user permission to determine if the UI was read-only or read/write by controlling the DAML of the 'Start Editing' button, but for simplicity of the sample this feature was removed.

 

0 Kudos
StephenRhea_NV5
Frequent Contributor

Thanks, @Wolf. I'll look into those because I'm currently modifying the DAML file in pre-build scripts for Beta and RC versions. I just added the button removal to those scripts as a quick fix, but converting to a Configuration may be a cleaner method all-around.

I'm pretty sure this is the case from those links, but can a user have multiple configurations installed at the same time? We develop multiple different Add-ins, and users can have any number installed. The Add-ins don't need to block existing Pro functionality and also don't need to affect other third-party Add-ins.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I guess i didn't understand your workflow correctly.  But in general, configurations allow you to modify the DAML when ArcGIS Pro starts up, but before the UI is activated.  This allows total control over the DAML content and hence the UI.  Add-ins are still loaded even if you run ArcGIS Pro with a Configuration, but you could modify the DAML of those Add-ins too (since the Add-in DAML will be included when Pro starts).

Now states & conditions can be used to control the visibility of Tabs, Groups in an Add-in (no need for a Configuration to do this).   This ProGuide is talking about tabs and groups:  ProGuide Ribbon Tabs and Groups · ArcGIS/arcgis-pro-sdk Wiki (github.com)

If you use a condition on an ArcGIS Pro button you can only disable the button, but you cannot hide it (or delete it) by using a condition.  But if you add your edit button (like the 'Delete' button) to an Edit group you can hide the whole group.  To test this out i modified the 'working with daml' sample code and hooked a new group 'myEdit_group' to the existing state/condition of the sample.  I can now use the 'Toggle State' button (which changes the condition) to hide or show the 'myEdit_group':

Wolf_0-1658962264429.png

after the toggle:

Wolf_1-1658962309053.png

This is the DAML that does the work:

 

<group id="myEdit_group" caption="My Edit Tools" keytip="X1"
               condition="example_state_condition">
      <button refID="esri_core_saveProjectButton" />
      <button refID="esri_core_saveProjectAsButton" />
</group>

 

and this adds the group to the mapping tab:

 

<updateModule refID="esri_mapping">
  <tabs>
    <updateTab refID="esri_mapping_homeTab">
      <insertGroup refID="myEdit_group"/>
    </updateTab>
  </tabs>
...

 

 

0 Kudos