Class: ControlHandle

Annotations. ControlHandle

Represents a base class for control handles for selected annotations that can be moved. Control handles are typically used to resize an annotation or other operations that modify the annotation.


new ControlHandle(x, y, width, height)

Creates a new ControlHandle with the specified dimensions.

Parameters:
Name Type Description
x number

the x-coordinate of the upper-left point

y number

the y-coordinate of the upper-left point

width number

the width of the control handle

height number

the width of the control handle

Members


handleHeight

Defines the height of all control handles. Default is 8.


handleWidth

Defines the width of all control handles. Default is 8.


selectionAccuracyPadding

Defines a padding for selection accuracy. Default is 1. Increase this value to make selection more forgiving.

Methods


draw(ctx, annotation, selectionBox, zoom)

Draws the control handle's appearance on the provided canvas context

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

the annotation canvas context

annotation Annotations.Annotation

the annotation to modify

selectionBox Annotations.Rect

the selection rect

zoom double

the current zoom level of the document


getDimensions(selectionBox)

Gets the dimensions of the control handle

Parameters:
Name Type Description
selectionBox Annotations.Rect

the selection rect


move(annotation, deltaX, deltaY, fromPoint, toPoint)

The method invoked when a control handle is moved. Override the method to provide custom behavior to control handles.

Parameters:
Name Type Description
annotation Annotations.Annotation

the annotation to modify

deltaX number

the change in x-coordinate

deltaY number

the change in y-coordinate

fromPoint Annotations.Point

the original page point (on mouse down)

toPoint Annotations.Point

the current page point

Returns:

return true if a redraw operation is necessary

Type
boolean

testSelection(annotation, selectionBox, zoom, x, y)

Determines if the provided point is a hit on the control handle. See Annotations.SelectionAlgorithm for usuable selection algorithms.

Parameters:
Name Type Description
annotation Annotations.Annotation

the annotation

selectionBox Annotations.Rect

the selection rect

zoom number

the current zoom level of the document

x number

the x-coordinate of the point to test, in page coordinates

y number

the y-coordinate of the point to test, in page coordinates

Returns:

true if the provided point is a hit

Type
Boolean