DEL 和 BACKSPACE 键被 WebBrowser 吃掉 [英] DEL and BACKSPACE keys get eaten from WebBrowser

查看:88
本文介绍了DEL 和 BACKSPACE 键被 WebBrowser 吃掉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在托管 System.Windows.Forms.WebBrowser 控件的 VSTO Outlook 加载项中有一个自定义任务窗格.一切正常,但在网络表单中 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.

感谢任何指点.

似乎单击 WebBrowser 不会激活父任务窗格.如果我添加一个简单的 TextBox 作为 WebBrowser 的兄弟,然后用鼠标单击 TextBox,任务窗格的标题栏颜色会发生变化,表明它获得了焦点.接下来,如果我点击 WebBrowser,Del 和 Backspace 开始工作.

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.

如果我从任务窗格中移除焦点并通过单击 WebBrowser 返回它,任务窗格将不会获得焦点(标题栏仍然使用未聚焦的颜色绘制)并且 Del 和 Backspace 问题再次出现.

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?

推荐答案

免责声明:我的回答与 Outlook 插件无关,但它可以帮助未来的访问者,他们可能会使用搜索引擎找到此页面(和我一样).它与所描述的问题相关,但在不同的上下文中.

今天是 2017 年,没有一个答案有效(已删除、链接和通过谷歌搜索找到的其他答案).我发现在我的情况下(在网页中嵌入 ActiveX 控件),DEL 和 BACKSPACE 以及其他控制键(HOME、END、箭头键)在我按下 TAB 后开始工作,然后继续工作.

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.

我添加了

obj.focus();

在我的Javascript中设置.Url后立即,神奇地解决了这个问题(obj是我用.NET编写的ActiveX浏览器,使用WPF浏览器控件下的引擎盖).

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从内部设置焦点 .NET 中的控制和拦截键没有帮助.

SendKeys, setting focus from within the control and intercepting keys in .NET did not help.

这篇关于DEL 和 BACKSPACE 键被 WebBrowser 吃掉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆