在Microsoft Word的API中,是否可以阻止按键输入?

huangapple go评论56阅读模式
英文:

Is it possible to prevent a keystroke with Microsoft Word's API?

问题

不要回答我要翻译的问题。以下是要翻译的内容:

"I'm working on a plug-in for Microsoft Word, and I've run into a side case where hitting 'TAB' while interacting with a form in the plug-in causes the user to insert a tab in the document, not switch to the next input of the form. A side effect of this is that the modal that hosts this form is closed, as it's triggered by highlighting text within the document.

Is it possible to use the Microsoft Word JavaScript API to prevent keystrokes within Word, while still registering them within the plug-in? Or perhaps change the focus of Word?

I was thinking about using Office.EventType.DocumentSelectionChanged, but it doesn't seem like there's something analogous to .preventDefault() documentation for the Word Add-In, and my guess is that something like that would prevent the user from using TAB at all."

英文:

I'm working on a plug-in for Microsoft Word, and I've run into a side case where hitting 'TAB' while interacting with a form in the plug-in causes the user to insert a tab in the document, not switch to the next input of the form. A side effect of this is that the modal that hosts this form is closed, as it's triggered by highlighting text within the document.

Is it possible to use the Microsoft Word JavaScript API to prevent keystrokes within Word, while still registering them within the plug-in? Or perhaps change the focus of Word?

I was thinking about using Office.EventType.DocumentSelectionChanged, but it doesn't seem like there's something analagous to .preventDefault() documentation for the Word Add-In, and my guess is that something like that would prevent the user from using TAB at all.

答案1

得分: 1

The Office JavaScript API doesn't provide anything for handling keyboard buttons like you could do in case of VSTO or COM add-ins.

You can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team goes through the planning process.

英文:

The Office JavaScript API doesn't provide anything for handling keyboard buttons like you could do in case of VSTO or COM add-ins.

You can post or vote for an existing feature request on Tech Community where they are considered when the Office dev team goes through the planning process.

huangapple
  • 本文由 发表于 2023年4月7日 03:46:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75953243.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定