none
Focus problems with Task Pane and WebControl in Outlook RRS feed

  • Question

  • I have a simple Outlook VSTO Add-in that is not working because focus does not move into the Task Pane, as a result sometimes the backspace key (and other keys) stop working. As if because the task pane doesn't have focus, outlook is eating the keys somewhere else.

    I've created a simple example project (VS2013):

    https://github.com/greenkiwi/FocusAwesomiumOutlookIssue/tree/dotNetWebControlOnly

    (Note you will need to check out the "dotNetWebControlOnly" branch)

    When I'm using it, I can see that sometimes clicking inside the textbox doesn't cause the task pane's task bar to change colors showing that it is focused.  

    I have added a Windows Textbox above the web control, where you can click and put focus into the pane.  When you do that, backspace works w/o a problem.  Then click somewhere else, like a message in your inbox, and click back in the textbox in the browser and focus doesn't move back in.

    I've seen a few posts elsewhere that seem to have similar problems

    StackOverflow:Outlook add in , text box , deletebackspace not working

    And they provide a way that works most of the time.  Even it's method sometimes doesn't work, and feels very much like a hack.

    Does anyone know what is going on and whether or not there are any ways to fix this problem?

    Thursday, December 12, 2013 12:19 AM

All replies

  • Hi Green,

    I try the sample you provided. You created a user control contains a textbox and a web browser into task pane. It was loaded as follows:

    >> I can see that sometimes clicking inside the textbox doesn't cause the task pane's task bar to change colors showing that it is focused. <<
    What do you mean by “task pane's task bar”?

    >> When you do that, backspace works w/o a problem <<

    What’s the problem? Do you mean you backspace was  inactive?

    >> click back in the textbox in the browser and focus doesn't move back in.<<

    I cannot reproduce this issue. I can see the focus moved back in the textbox. I suggest you looking at task manage to check whether current machine is running slowly.

    What’ the version of Outlook are you using?

    Since I can’t reproduce this issue, would you mind sharing  screenshots for us?


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 20, 2013 1:52 AM
    Moderator
  • I'll actually try to take a video of it rather than screen shots, that should be easier to see what is happening.

    There are two controls, the native forms textbox and a web browser with a html textbox in it.

    What I found is that sometimes when I click away (in a message for example) and click back inside the html textbox, the backspace key is not active.  I can type but cannot delete text.  The backspace key just doesn't do anything when you hit it.

    When I click inside the native textbox control focus always moves into the task pane and everything works as it should.

    What I'm talking about the "task pane task bar", I was referring to the fact that the bar at the top of the task pane changes color when focus is in the task pane as opposed to when it is somewhere else in outlook.

    As for versions of outlook, I've seen it with Outlook 2007, 2010 and 2013.  All the machines have been recent-ish machines, so I don't believe that it is a performance issue.

    Friday, December 20, 2013 5:19 AM
  • Here is a video of it, I hope it helps show the problem.

    http://www.youtube.com/watch?v=EstovWR6rho&feature=youtu.be

    Sorry for the quality, I had to take it with my iPhone.
    Friday, December 20, 2013 7:20 PM
  • Hi Green.

    Thanks for your feedback.

    I'm facing the same issue as you mentioned.

    I'm trying to involve someone familiar with this topic to further look at this issue.

    There might be some time delay. Your patience would be appreciated.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, December 25, 2013 9:24 AM
    Moderator
  • Hi George,

    Thanks for looking into it and helping find someone who could help.

    For another data point, I have tested it with an Awesomium web control in the custom task pane and it also has this problem.

    I'm happy to be patient.  I'm subscribed to this, so if I can be of any other help, just let me know.

    For another data point, I tried the same thing in Add-in-express, their form regions, even when in the DockLeft/Right positions all don't have this focus issue.  And their dock regions are supposed to be based on CustomTaskPane.


    Wednesday, December 25, 2013 7:39 PM
  • Hi George,

    FYI There are alive issues even with Add-in Express based regions. For example, you can find the following entry in the KNOWN ISSUES section:

    WebBrowser Control Issues: In Outlook, Excel, Word and PowerPoint, a host application may lose the focus after activating the WebBrowser control residing on an advanced region or advanced task pane.


    Thursday, December 26, 2013 10:09 AM
  • Thanks for the heads up, I didn't see the known issues earlier.  It's interesting that the problem is much less prevalent in ADX.

    I hope that there is a solution to this issue.

     
    Wednesday, January 8, 2014 8:23 PM
  • Hi Green,

    I'll try to figure out whats going on here and let you know the updates. If you feel this issue is having a severe business impact, then visit the below link to see the various paid support options that are available to better meet your needs. http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone If we determine that the issue is the result of a product issue, then the service request will be a No-Charge case and you won't be charged.

    Friday, March 21, 2014 9:20 PM
  • This works for me in the scenario of adding WebBrowser control to custom task pane.

    Basically handle click event from html doc in the event handler, in which set the focus to the host control of the webbrowser first, then set focus to the clicked html element.
    One needs to add reference to MSHTML com object to use HtmlDocument .

    In your UserControl

     private void InitializeComponent()
     {
      this.webBrowser1 = new System.Windows.Forms.WebBrowser();
      webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
     }

     void webBrowser1_DocumentCompleted(object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
     {
                HtmlDocument doc;
                doc = webBrowser1.Document;
                doc.Click += doc_Click;
     }

    void doc_Click(object sender, HtmlElementEventArgs e)
    {
                this.Focus();  // force user control to have the focus
                HtmlElement elem = webBrowser1.Document.GetElementFromPoint(e.ClientMousePosition);
                elem.Focus(); // then let the clicked control to have focus
    }

    Tuesday, November 4, 2014 10:14 PM
  • I am also facing the same issue with outlook plugin and html form. And the workaround you have suggested works for me but it impacts other controls like dropdown where I am unable to select value easily due to focus code.

    Also, I have one hyperlink which launches one child form which goes back due to focus.

    Is there any other workaround for this issue ? Or any idea whether this issue gets resolved with any future update of outlook 2010 ? 

    Thanks,

    Manoj


    ManojPatel

    Monday, June 4, 2018 1:24 PM
  • Hello Manoj,

    Hosting a web browser inside any Office application is really a bad idea. Even various issues remain in all Office and .NET Framework versions caused by a partial incompatibility of the WPF core and Office GUI.

    As a workaround you may consider re-creating the GUI using Windows forms controls.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, June 4, 2018 6:45 PM