PdfContextMenuRequest class
A context menu the host is asked to render, with everything the viewer already resolved about the gesture.
Delivered to PdfViewer.onContextMenuRequested, which fires only when
PdfViewer.contextMenuEnabled is false: with the default menu disabled,
the viewer prepares the same selection context the stock menu would have
had, then hands the gesture to the host instead of opening a menu itself.
The host typically wraps this in showMenu<_T>(context, position: ...)
anchored at globalPosition, and branches on target:
onContextMenuRequested: (request) {
switch (request.target) {
case PdfContextMenuTarget.text:
// request.selectedText is the word under the cursor
case PdfContextMenuTarget.annotation:
// request.annotation.subtype names the kind
case PdfContextMenuTarget.lockedAnnotation:
// offer Unlock
case PdfContextMenuTarget.formWidget:
case PdfContextMenuTarget.emptyPage:
}
}
Because the target is resolved for it, a host does not need a
PdfEditingController of its own - which is what makes this work inside
the drop-in PdfReader, whose session is private.
Constructors
- PdfContextMenuRequest({required Offset globalPosition, required int pageIndex, required (double, double) pagePoint, required PdfContextMenuTarget target, PdfEditingController? controller, int? slot, PdfAnnotation? annotation, String selectedText = ''})
-
const
Properties
- annotation → PdfAnnotation?
-
The annotation under the gesture, for PdfContextMenuTarget.annotation
and PdfContextMenuTarget.lockedAnnotation. Null otherwise.
final
- controller → PdfEditingController?
-
The editing session behind the viewer, when there is one - the
editing session, or the reader's standalone form-fill controller.
Null in a plain reader with neither.
final
- globalPosition → Offset
-
Where the gesture landed, in global Flutter coordinates - anchor the
menu here.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- pageIndex → int
-
The page the gesture landed on.
final
- pagePoint → (double, double)
-
Where the gesture landed, in page coordinates (points).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedText → String
-
The page text selected when the request was made. Non-empty for
PdfContextMenuTarget.text whenever there was a word to select.
final
- slot → int?
-
The /Annots slot of annotation, when the viewer resolved the hit
through an editing session. Null in a reader without one, and for
targets that are not an annotation.
final
- target → PdfContextMenuTarget
-
What the gesture landed on.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited