Anchor

优质
小牛编辑
126浏览
2023-12-01

Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated.

Constructors

new Anchor(Document doc, Number row, Number column)

Creates a new Anchor and associates it with a document.

docDocumentRequired. The document to associate with the anchor
rowNumberRequired. The starting row position
columnNumberRequired. The starting column position

Events

Anchor.on("change", function(Object e))

Fires whenever the anchor position changes.

Both of these objects have a row and column property corresponding to the position.

Events that can trigger this function include setPosition().

eObjectRequired. An object containing information about the anchor position. It has two properties:

  • old: An object describing the old Anchor position
  • value: An object describing the new Anchor position

Methods

Anchor.detach()

When called, the 'change' event listener is removed.

Anchor.getDocument()

返回值: Document

Returns the current document.

Anchor.getPosition()

返回值: Object

Returns an object identifying the row and column position of the current anchor.

Anchor.onChange()

Undocumented

Anchor.setPosition(Number row, Number column, Boolean noClip)

Sets the anchor position to the specified row and column. If noClip is true, the position is not clipped.

rowNumberRequired. The row index to move the anchor to
columnNumberRequired. The column index to move the anchor to
noClipBooleanRequired. Identifies if you want the position to be clipped