DEL 和 BACKSPACE 键被 WebBrowser 吃掉
我在 VSTO Outlook 加载项中有一个自定义任务窗格,其中托管一个 System.Windows.Forms.WebBrowser 控件。一切正常,但在 Web 表单中 DEL 和 BACKSPACE 键不起作用。就好像有什么东西在这些键到达浏览器之前就吃掉了它们一样。
任何指示表示赞赏。
编辑:
单击 WebBrowser
似乎不会激活父任务窗格。如果我添加一个简单的 TextBox
作为 WebBrowser
的同级,然后用鼠标单击 TextBox
,任务窗格的标题栏颜色会发生变化,表明它获得了焦点。接下来,如果我单击 WebBrowser
,Del 和 Backspace 就会开始工作。
如果我从任务窗格中删除焦点并通过单击 WebBrowser
返回到它,则任务窗格不会接收焦点(标题栏仍涂有未聚焦的颜色),并且会再次出现 Del 和 Backspace 问题。
为什么任务窗格不知道浏览器接收焦点?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
免责声明:我的回答与 Outlook 插件无关,但它可能会对未来的访问者有所帮助,他们可能会使用搜索引擎找到此页面(与我一样)。它与所描述的问题相关,但在不同的上下文中。
今天是 2017 年,所有答案都不起作用(已删除、链接以及通过谷歌搜索找到的其他答案)。我发现在我的情况(网页中嵌入ActiveX控件)中,DEL和BACKSPACE以及其他控制键(HOME、END、箭头键)在我按TAB后开始工作,并在之后继续工作。
添加
我在Javascript中设置
.Url
后立即 ,它神奇地解决了问题(obj
是我用.NET编写的ActiveX浏览器,在引擎盖下使用WPF浏览器控件)。SendKeys ,从内部设置焦点控制和拦截 .NET 中的键没有帮助。
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
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.