Outlook add in , text box , delete\\backspace not working

…衆ロ難τιáo~ 提交于 2019-12-08 05:06:32

Ok I solved the problem ,

The problem is that the custom task pane in not always gets fucos from the outlook.

So, I raised an event every time that there is "onclick" for all the pane, and then forced the pane to be in focus.

I am a few years late to the party but I managed to fix this. The easiest way to fix this is to ensure proper focus is given to the input fields, so you will need to be able to run your own javascript on whatever page is being loaded.

The javascript I run on the page is as follows (using jQuery):

$(document).on("click", function (e) {
  // first let the add-in give focus to our CustomTaskPane
  window.external.focus();
  // then in our web browser give focus to whatever element was clicked on
  $(e.target).focus();
});

the window.external variable contains code run from the plugin (c# or VB I assume) which is exposed so we can interact from web page back to the add-in.

In the add-in code for the custom taskpane set the context of window.external:

// event when webBrowser is finished loading document
private void webBrowser1_DocumentCompleted(object sender,     WebBrowserDocumentCompletedEventArgs e)
    {
        // sets context of window.external to functions defined on this context
        webBrowser1.ObjectForScripting = this;
    }

And a public method for focusing:

// can be called by the web browser as window.external.focus()
public void focus()
{
    this.Focus();
}

This worked for me, and I hope it helps others. Although do note that this probably doesn't work if the user keyboard navigates using tab, but you can either extend this code for that use case, or safely assume that the average outlook user will have his hand glued to the mouse.

Turns out this is an easy issue to fix.

Just write

class MyBrowser : WebBrowser {}

Then use MyBrowser instead of the .NET one.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!