Word.ContentControlSelectionChangedEventArgs interface
提供有关引发 contentControlSelectionChanged 事件的内容控件的信息。
注解
示例
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/word/10-content-controls/content-control-onselectionchanged-event.yaml
await Word.run(async (context) => {
const contentControls: Word.ContentControlCollection = context.document.contentControls;
contentControls.load("items");
await context.sync();
if (contentControls.items.length === 0) {
console.log("There aren't any content controls in this document so can't register event handlers.");
} else {
for (let i = 0; i < contentControls.items.length; i++) {
eventContexts[i] = contentControls.items[i].onSelectionChanged.add(contentControlSelectionChanged);
contentControls.items[i].track();
}
await context.sync();
console.log("Added event handlers for when selections are changed in content controls.");
}
});
...
async function contentControlSelectionChanged(event: Word.ContentControlSelectionChangedEventArgs) {
await Word.run(async (context) => {
console.log(`${event.eventType} event detected. IDs of content controls where selection was changed:`, event.ids);
});
}
属性
event |
事件类型。 请参阅Word。EventType 了解详细信息。 |
ids | 获取内容控件 ID。 |
source | 事件的源。 通过共同创作) ,它可以是本地或远程 (。 |
属性详细信息
eventType
事件类型。 请参阅Word。EventType 了解详细信息。
eventType: Word.EventType | "ContentControlDeleted" | "ContentControlSelectionChanged" | "ContentControlDataChanged" | "ContentControlAdded" | "CommentDeleted" | "CommentSelected" | "CommentDeselected" | "CommentChanged" | "CommentAdded" | "ContentControlEntered" | "ContentControlExited" | "ParagraphAdded" | "ParagraphChanged" | "ParagraphDeleted" | "AnnotationClicked" | "AnnotationHovered" | "AnnotationInserted" | "AnnotationRemoved" | "AnnotationPopupAction";
属性值
Word.EventType | "ContentControlDeleted" | "ContentControlSelectionChanged" | "ContentControlDataChanged" | "ContentControlAdded" | "CommentDeleted" | "CommentSelected" | "CommentDeselected" | "CommentChanged" | "CommentAdded" | "ContentControlEntered" | "ContentControlExited" | "ParagraphAdded" | "ParagraphChanged" | "ParagraphDeleted" | "AnnotationClicked" | "AnnotationHovered" | "AnnotationInserted" | "AnnotationRemoved" | "AnnotationPopupAction"
注解
ids
source
事件的源。 通过共同创作) ,它可以是本地或远程 (。
source: Word.EventSource | "Local" | "Remote";
属性值
Word.EventSource | "Local" | "Remote"