问题
I have a custom task pane in a VSTO Outlook add-in which hosts a System.Windows.Forms.WebBrowser
control. All works well but in web forms DEL and BACKSPACE keys do not work. As if something eats those keys before they get to the browser.
Any pointers are appreciated.
EDIT:
It seems that clicking the WebBrowser
does not activate the parent task pane. If I add a simple TextBox
as a sibling to WebBrowser
and then click TextBox
with a mouse, task pane's title bar color changes indicating it got focus. Next if I click WebBrowser
, Del and Backspace start working.
If I remove focus from task pane and get back to it by clicking WebBrowser
, task pane does not receive focus (title bar remains painted with unfocused color) and the Del and Backspace problem reoccurs.
Why is task pane unaware of browser receiving focus?
回答1:
Disclaimer: my answer is not related to Outlook plug-in, but it may help future visitors, who may find this page using a search engine (same as I did). It is relevant to the problem described, but in a different context.
Today is 2017, none of the answers worked (deleted, linked and others found by google search). I discovered that in my situation (embedded ActiveX control in a web page), DEL and BACKSPACE as well as other control keys (HOME, END, arrow keys) start working after I press TAB, and continues to work after that.
I added
obj.focus();
Immediately after setting the .Url
in my Javascript, and it magically solved the problem (obj
is my ActiveX browser written in .NET, using WPF browser control under the hood).
SendKeys, setting focus from within the control and intercepting keys in .NET did not help.
来源:https://stackoverflow.com/questions/6055916/del-and-backspace-keys-get-eaten-from-webbrowser