Select to view content in your preferred language

Changing custom tab to active tab on open

158
3
02-13-2025 10:23 AM
Jeff-Reinhart
Regular Contributor

What is the best way to change the active tab to a custom tab when a custom add-in is loaded?

Use case: The custom add-in will be part of a Pro project that is on a server. When the user opens the project, the tab they should see is the custom tab. 99% of operations they will be doing will be through tools on this tab. Since the Pro project is on a server, the add-in will not affect the user’s normal local Pro settings (particularly that the “Map” tab is the first active tab.

I have <insertModule autoLoad="true"> so the module code is running when the project with the add-in opens. I have set the custom tab as the first tab from the left using <tab insert="before" placeWith="esri_mapping_homeTab">

It seems to work to set the active tab using FrameworkApplication.ActivateTab("my_tab_id"), but I am having trouble finding the event to subscribe to.

I have tried ProjectOpenedEvent.Subscribe(), but the Ribbon does not seem to be initialized when that event fires.

I have also tried ActivePaneInitializedEvent.Subscribe(). Running FrameworkApplication.ActivateTab("my_tab_id") from that event sets the custom tab as active briefly, but eventually another event switches the active tab back to the esri_mapping_homeTab.

I have looked through the other events and am not seeing a better one to subscribe to.

Without running FrameworkApplication.ActivateTab("my_tab_id"), just having the custom tab as the first from the left makes it the active tab for a few seconds before esri_mapping_homeTab becomes active, so maybe there is a way to override the event that changes the active tab to esri_mapping_homeTab?

0 Kudos
3 Replies
Jeff-Reinhart
Regular Contributor

I see now that this is happening due to tabs changing based on context. Looking for a way to turn that off or redirect when focus is on a Map to my custom tab instead of the esri_mapping_homeTab...

0 Kudos
Jeff-Reinhart
Regular Contributor

Sort of solved it. Turned off the Map tab in Options | Customize the Ribbon. Without the tab there, whatever event was firing on startup to change the active tab either doesn't fire or fails. Not a great solution to have to hide the map tab from users. Would rather be able to turn off context based tab changes as suggested in this ArcGIS Pro Idea.

0 Kudos
Jeff-Reinhart
Regular Contributor

Solved this by turning off the tabs I don't need in Config.daml using updateModule and deleteTab. The examples are very helpful.

0 Kudos