Functions for meeting

更新时间:
复制 MD 格式

This topic describes how to obtain a specified range or shape object, and listen to the scroll change events and selection change events when you use a text document.

Obtain the range based on a location in the current view

Obtain the range or shape object from the upper-left corner of the text body to a specified point.

  • Syntax

    Expression.ActiveDocument.ActiveWindow.RangeFromPoint(x, y)

    Expression: the document type application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    x

    Number

    Yes

    The horizontal distance in pixels from the upper-left corner of the text body to the specified point. Page scrolls do not affect the value.

    y

    Number

    Yes

    The vertical distance in pixels from the upper-left corner of the text body to the specified point. Page scrolls do not affect the value.

  • Return value

    Returns the specified range or shape object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain the range or shape object from the upper-left corner of the text body to the specified point.
      const range = await app.ActiveDocument.ActiveWindow.RangeFromPoint(10, 10);
      console.log(range);
     
    }

Display a specified range or shape

Scroll the document window to display a specified range or shape object.

  • Syntax

    Expression.ActiveDocument.ActiveWindow.ScrollIntoView(range)

    Expression: the document type application object.

  • Parameters

    Parameter

    Type

    Required

    Description

    range

    Range

    Yes

    The range or shape object to be displayed.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
    
      // Obtain the range object.
      const range = await app.ActiveDocument.ActiveWindow.RangeFromPoint(10, 10);
      console.log(range);
    
      // Scroll the document window to display the specified range.
      await app.ActiveDocument.ActiveWindow.ScrollIntoView(range)
     
    }

Listen to the scroll change events

  • Syntax

    Expression.Sub.WindowScrollChange = Function

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Listen to the scroll change events.
      app.Sub.WindowScrollChange = ({ Data }) => {
        // The coordinates of the upper-left corner.
        console.log(Data.scrollLeft, Data.scrollTop);
      }
    }

Listen to the selection change events

  • Syntax

    Expression.Sub.WindowSelectionChange = Function

    Expression: the document type application object.

  • Example

    async function example() {
      await instance.ready();
    
      const app = instance.Application;
      
      // Listen to the selection change events.
      app.Sub.WindowSelectionChange = (e) => {
        const { begin, end } = e;
        // The start position and end position of the selection.
        console.log ('start position:${begin}, end position:${end}');
      }
    
      // Set the selection.
      setTimeout( () => {
        await app.ActiveDocument.Range(100,100).SetRange(10, 10)
      }, 2000);
    }