title: Gui.Window ContextClick
body: <p>Is there a way to add an Event.ContextClick to a Gui.Window in a Unity Editor script?</p>
  
  <p>The following is my context menu method that I've tried calling from both <strong>OnGUI()</strong> and my window's <strong>WindowFunction</strong> (call sites denoted below as "<strong>site: no luck</strong>").  I have not been able to get the "Success" message to show up unless I'm right clicking directly in the main editor window. If I right click in any of the Gui.Windows I have created, the ContextClick event doesn't show up.  </p>
  
  <pre><code>void OnStateContextMenu(){
      Event evt = Event.current;
  
      // Ignore anything but contextclicks
      if(evt.type != EventType.ContextClick)return;
  
      Debug.Log("Success");
  
      // Add generic menu at context point
      GenericMenu menu = new GenericMenu();
      menu.AddItem (new GUIContent ("AddState"),false,AddState,evt.mousePosition);
      menu.ShowAsContext ();
      evt.Use();
  }
  </code></pre>
  
  <p>And the call site(s):</p>
  
  <pre><code>void doWindow(int id){
      // OnStateContextMenu(); //site1: no luck
      GUI.DragWindow();
  }
  
  void OnGUI(){
      OnStateContextMenu(); //site2: no luck here either
      BeginWindows();
      wndRect = GUI.Window(0,wndRect,doWindow,"StateWnd");   
      EndWindows();
  }
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>For reference, green area responds to right-click, red area does not.  But I want it to. The right-click menu I've created has specific actions I only want visible if the mouse cursor right clicks inside one of my windows, the 'Hello' in the image.  Note:  Ignore the button, right click doesn't work anywhere inside that window.</p>
  
  <p><img src="https://i.stack.imgur.com/JjpnD.png" alt="enter image description here"></p>