Share via


Word.ContentControlSelectionChangedEventArgs interface

contentControlSelectionChanged イベントを発生させたコンテンツ コントロールに関する情報を提供します。

注釈

[ API セット: WordApi 1.5 ]

// 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 = 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);
  });
}

プロパティ

eventType

イベントの種類。 「Word」を参照してください。詳細については、EventType を参照してください。

ids

コンテンツ コントロール ID を取得します。

source

イベントのソース。 ローカルまたはリモート (共同編集を使用) できます。

プロパティの詳細

eventType

イベントの種類。 「Word」を参照してください。詳細については、EventType を参照してください。

eventType: Word.EventType | "ContentControlDeleted" | "ContentControlSelectionChanged" | "ContentControlDataChanged" | "ContentControlAdded" | "ContentControlEntered" | "ContentControlExited" | "ParagraphAdded" | "ParagraphChanged" | "ParagraphDeleted" | "AnnotationClicked" | "AnnotationHovered" | "AnnotationInserted" | "AnnotationRemoved";

プロパティ値

Word.EventType | "ContentControlDeleted" | "ContentControlSelectionChanged" | "ContentControlDataChanged" | "ContentControlAdded" | "ContentControlEntered" | "ContentControlExited" | "ParagraphAdded" | "ParagraphChanged" | "ParagraphDeleted" | "AnnotationClicked" | "AnnotationHovered" | "AnnotationInserted" | "AnnotationRemoved"

注釈

[ API セット: WordApi 1.5 ]

ids

コンテンツ コントロール ID を取得します。

ids: number[];

プロパティ値

number[]

注釈

[ API セット: WordApi 1.5 ]

source

イベントのソース。 ローカルまたはリモート (共同編集を使用) できます。

source: Word.EventSource | "Local" | "Remote";

プロパティ値

Word.EventSource | "Local" | "Remote"

注釈

[ API セット: WordApi 1.5 ]