SelectionChange用于输入和退格键 [英] SelectionChange for enter and backspace keys

查看:175
本文介绍了SelectionChange用于输入和退格键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我们的VSTO插件需要知道当前的选择,以便我们可以将我们的任务窗格与当前选择同步。我们使用SelectionChanged事件来注册我们的任务窗口同步例程。问题是此事件不会在Enter或退格键上触发。
我们特别感兴趣的是Enter / backspace导致段落更改的情况(在段落中的最后一个字符的退格处输入和段落删除)。这对我来说似乎是一个错误,当删除键触发时,SelectionChange不会在退格键上触发


是否还有其他解决方法来检测此段落更改状态?

解决方案

您好,


VSTO没有提供处理键盘输入的任何内容。作为一种解决方法,您可以使用
设置键盘钩子
SetWindowsHookEx
功能来自Windows API。见
使用快捷键调用Office加载项中的函数

如何使用VSTO在MSword中捕获keypress事件?
以获取更多信息。


Hello all,

Our VSTO addin needs to know the current selection so we can sync our taskpane with current selection. We are using the SelectionChanged event to register our taskpane synch routine. The problem is that this event doesn't fire on Enter or backspace key. We are specifically interested in the scenarios where the Enter/backspace results in a paragraph change(para add on enter and paragraph remove on backspace of the last character in a para). It seems like a bug to me that SelectionChange wont fire on backspace when the delete key does fires it.

Is there any other workaround to detect this paragraph change state?

解决方案

Hello,

VSTO doesn't provide anything for handling keyboard input. As a workaround you can set up a keyboard hook using the SetWindowsHookEx function which comes from Windows API. See Using shortcut keys to call a function in an Office Add-in and How to trap keypress event in MSword using VSTO? for more information.


这篇关于SelectionChange用于输入和退格键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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