英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论