PDFiumVCL Docs

HasFormFieldAt property

Component: TPdf  ·  Unit: PDFium
Hit-test that returns True when a form field widget covers the given page coordinate.

Syntax

property HasFormFieldAt[X, Y: Single]: Boolean; // read only

Description

HasFormFieldAt performs a hit-test on the currently active page: it returns True when the given (X, Y) coordinate falls inside any widget annotation rectangle. Coordinates are in PDF user space — same coordinate system as PageWidth / PageHeight, with the origin at the bottom-left, X increasing rightward, Y increasing upward, units in points (1/72 inch).

The property returns False when Active is False, when the document has no AcroForm widgets, or when the supplied coordinate misses every widget rectangle. It is a constant-time wrapper around PDFium’s FPDFPage_HasFormFieldAtPoint — ideal for mouse-move / hover feedback in a viewer where the value is queried many times per second.

The hit-test honors widget rectangle only — not appearance bounds. Push buttons or check boxes whose visible glyph is smaller than the widget rect still report True for the whole rect. Pair with FormFieldInfoAt[X, Y] to obtain the matched field’s record once the hit-test confirms the cursor is over a field; that pattern avoids the heavier info-fetch on every mouse-move event.

Remarks

Example

procedure TForm1.PdfView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var PageX, PageY: Double;
begin
  PdfView1.DeviceToPage(X, Y, PageX, PageY);
  if Pdf1.HasFormFieldAt[PageX, PageY] then
    PdfView1.Cursor := crHandPoint
  else
    PdfView1.Cursor := crDefault;
end;

See Also

FormFieldAt, FormFieldInfoAt, FormFieldCount, TPdfView.DeviceToPage