Working through this answer to someone else's question on the context menu, I've added a number of new buttons to the map's right-click context menu that do various, not feature specific, things like zooming in or out of the extent.
Now I'd like to add a tool that needs to know the feature that is located where the right-click took place, but have no idea how to do that. I'd like to add a button to the context menu that will display data related to the feature at the point the user right clicked.
Below is the code added to config.daml to update the context menu:
<updateModule refID="esri_mapping">
<menus>
<updateMenu refID="esri_mapping_popupToolContextMenu">
<insertButton refID="FNSBArcGISProAddin_ParcelSelectRC" insert="before" placeWith="esri_mapping_cameraPropertiesControl" />
<insertButton refID="FNSBArcGISProAddin_ZoomInFixed" insert="before" placeWith="esri_mapping_cameraPropertiesControl" />
<insertButton refID="FNSBArcGISProAddin_ZoomOutFixed" insert="before" placeWith="esri_mapping_cameraPropertiesControl" />
<insertButton refID="FNSBArcGISProAddin_FullExtent" insert="before" placeWith="esri_mapping_cameraPropertiesControl" />
</updateMenu>
</menus>
</updateModule>
Unfortunately, for the class behind FNSBArcGISProAddin_ParcelSelectRC, I do not know how to capture the information for the right click location.
Solved! Go to Solution.
Hi Roger,
This can be done via the ContextMenuDataContext property as described in the pro-sdk wiki: adding-commands-to-the-context-menu
Essentially, you can get the right-click location by casting ContextMenuDataContext to a windows point.
//get the screen location of the right click
var cmdc = (System.Windows.Point)FrameworkApplication.ContextMenuDataContext;
You can then cast to a map point to do useful things such as searching etc.
As an example, this is used in the replace sketch editing sample where the user replaces the current sketch with a feature that is right-clicked on. (the button is inserted in the daml of course)
Hi Roger,
This can be done via the ContextMenuDataContext property as described in the pro-sdk wiki: adding-commands-to-the-context-menu
Essentially, you can get the right-click location by casting ContextMenuDataContext to a windows point.
//get the screen location of the right click
var cmdc = (System.Windows.Point)FrameworkApplication.ContextMenuDataContext;
You can then cast to a map point to do useful things such as searching etc.
As an example, this is used in the replace sketch editing sample where the user replaces the current sketch with a feature that is right-clicked on. (the button is inserted in the daml of course)
Thanks much! Not sure how I missed that part of the wiki. I was able to quickly get this working once I had a look.