<?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 Re: How to determine the user selected context menu item in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1078030#M6862</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;No you cant tell what context menu item the user has chosen.&lt;/P&gt;&lt;P&gt;You can add your own command to the context menu and get the location of the mouse right-click if that helps.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jul 2021 21:29:17 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-07-12T21:29:17Z</dc:date>
    <item>
      <title>How to determine the user selected context menu item</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1077683#M6858</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We are developing a customized tool using ArcGIS Pro SDK (v2.8) and .NET Framework. Is there any possibility to identify the user selected context menu item?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, if the user select "Parallel" context menu option, can we determine the selected option. Please find the below snapshot for reference.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SashiRekha_0-1626069492391.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/18200iD75F4E89C296EB41/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SashiRekha_0-1626069492391.png" alt="SashiRekha_0-1626069492391.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any ideas/inputs are most appreciated.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 06:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1077683#M6858</guid>
      <dc:creator>SashiRekha</dc:creator>
      <dc:date>2021-07-12T06:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine the user selected context menu item</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1078030#M6862</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;No you cant tell what context menu item the user has chosen.&lt;/P&gt;&lt;P&gt;You can add your own command to the context menu and get the location of the mouse right-click if that helps.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 21:29:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1078030#M6862</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-12T21:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine the user selected context menu item</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1092093#M7066</link>
      <description>&lt;P&gt;In the OnClick event handler for the menu item(s) you could write something to indicate which item was clicked to a text file and then read that text file elsewhere. For example, I'm using a dynamic menu and, in the OnClick method, I write the value of the clicked item index to the text file.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Aug 2021 04:04:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1092093#M7066</guid>
      <dc:creator>DavidHowes</dc:creator>
      <dc:date>2021-08-25T04:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine the user selected context menu item</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1093199#M7084</link>
      <description>&lt;P&gt;What I wrote in my previous response works, but a more elegant solution that I'd forgotten about is to use a "context" class, which "can be seen as a bucket to pass information around" - see &lt;A href="https://stackoverflow.com/questions/6145091/the-term-context-in-programming" target="_self"&gt;https://stackoverflow.com/questions/6145091/the-term-context-in-programming&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;1. Create a static class with a static public property anywhere you like&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;	namespace ContextMenuDemo
	{
		public static class Context
		{
			public static int ClickedIndex = default;
		}
	}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;2. Set the property in the OnClick event handler for the menu&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;	protected override void OnClick(int index)
	{
		Context.ClickedIndex = index;
	}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;3. Access the property wherever required, e.g.,&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;	private void ShowContextMenu(MapPoint clickedPoint)
	{
		var contextMenu = FrameworkApplication.CreateContextMenu("ContextMenu_Menus_DynamicMenu", () =&amp;gt; ClientPoint);

		contextMenu.Closed += (returnObject, routedEventArgs) =&amp;gt;
		{
			MessageBox.Show(Context.ClickedIndex.ToString());
		};
	}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;It's a little confusing, but the word "Context" as the class name has nothing to do with the word "Context" in the namespace name or the menu type. You can call the class whatever you like. I just wanted to stick to the terminology describing the purpose of the class.&lt;/P&gt;&lt;P&gt;I also tried a couple of other options without success:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;1. Accessing a context menu class property via the objects passed to the menu closed event handler;&lt;BR /&gt;2. Using a delegate passed to the menu class instance to set a property on the class in which the menu is created.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 16:46:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-determine-the-user-selected-context-menu/m-p/1093199#M7084</guid>
      <dc:creator>DavidHowes</dc:creator>
      <dc:date>2021-08-27T16:46:06Z</dc:date>
    </item>
  </channel>
</rss>

