title: Excel CustomTaskPane with WebBrowser control - keyboard/focus issues
body: <p>I am having this exact issue <a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/e417e686-032c-4324-b778-fef66c7687cd/excel-customtaskpane-with-webbrowser-control-keyboardfocus-issues?forum=vsto" rel="noreferrer">https://social.msdn.microsoft.com/Forums/vstudio/en-US/e417e686-032c-4324-b778-fef66c7687cd/excel-customtaskpane-with-webbrowser-control-keyboardfocus-issues?forum=vsto</a>  </p>
  
  <p>Also mentioned here <a href="https://connect.microsoft.com/VisualStudio/feedback/details/521465/the-focus-issue-between-excel-cells-and-excel-customtaskpane-with-webbrowser-control" rel="noreferrer">https://connect.microsoft.com/VisualStudio/feedback/details/521465/the-focus-issue-between-excel-cells-and-excel-customtaskpane-with-webbrowser-control</a></p>
  
  <p>I am writing an Excel 2010 plugin using Visual Studio Professional 2013.  I've created a simple CustomTaskPane with a System.Windows.Forms.WebBrowser child filing it.  The plugin works just fine and I am able to navigate inside the webbrowser by click and change the state of checkboxes.</p>
  
  <p><img src="https://i.stack.imgur.com/P2VmV.png" alt="enter image description here"></p>
  
  <p>When I click on an input textbox I get focus and I see the cursor blinking, but when I start typing the text is sent to Excel and written into a cell instead of the textbox inside the browser.</p>
  
  <p>I add the custom taskpane when the ribbon loads.</p>
  
  <pre><code>private void Ribbon_Load(object sender, RibbonUIEventArgs e)
  {
    TaskPaneView taskPaneView = new TaskPaneView();
    Microsoft.Office.Tools.CustomTaskPane myTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(taskPaneView, "Title");
    myTaskPane.Visible = true;
  }
  </code></pre>
  
  <p>When I click on the textbox then hit <code>F6</code> it works correctly.  The customtaskpane header darkens slightly and text is captured in the textbox.</p>
  
  <p>How can i fix this issue so that when I click on the input textbox the text goes into the box instead of Excel?</p>
  
  <p><strong>EDIT: Ok, I did some more testing.</strong>  If I add events on my TaskPaneView to track mouse enter and click they work, but only if I remove the web browser child.  Meaning the web browser is somehow blocking these events and preventing the TaskPaneView from understanding it has focus.  If I also added a textbox form control into the TaskPaneView along side the browser, the textbox works totally fine and the TaskPaneView understands it has focus and then the input text field inside the browser then starts works.  If I call the focus method directly on the web browser, the TaskPaneView understands it has focus and everything works perfectly.  So clearly the issue isn't really with the keyboard, but instead an issue of the TaskPaneView not being told it has focus when the browser is clicked on so the keystrokes go to the wrong area.  If I can find a way to make TaskPaneView understand it has focus everythign should work.</p>