Skip to content

Commit c49af0d

Browse files
committed
Add comments
1 parent 05f8b63 commit c49af0d

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

lib/src/widgets/text_selection.dart

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ TextSelection localSelection(Node node, TextSelection selection, fromParent) {
1919
extentOffset: math.min(selection.end - offset, node.length - 1));
2020
}
2121

22+
/// The text position that a give selection handle manipulates. Dragging the
23+
/// [start] handle always moves the [start]/[baseOffset] of the selection.
2224
enum _TextSelectionHandlePosition { START, END }
2325

2426
/// internal use, used to get drag direction information
@@ -56,7 +58,14 @@ class DragTextSelection extends TextSelection {
5658
}
5759
}
5860

61+
/// An object that manages a pair of text selection handles.
62+
///
63+
/// The selection handles are displayed in the [Overlay] that most closely
64+
/// encloses the given [BuildContext].
5965
class EditorTextSelectionOverlay {
66+
/// Creates an object that manages overlay entries for selection handles.
67+
///
68+
/// The [context] must not be null and must have an [Overlay] as an ancestor.
6069
EditorTextSelectionOverlay(
6170
this.value,
6271
this.handlesVisible,
@@ -80,16 +89,70 @@ class EditorTextSelectionOverlay {
8089

8190
TextEditingValue value;
8291
bool handlesVisible = false;
92+
93+
/// The context in which the selection handles should appear.
94+
///
95+
/// This context must have an [Overlay] as an ancestor because this object
96+
/// will display the text selection handles in that [Overlay].
8397
final BuildContext context;
98+
99+
/// Debugging information for explaining why the [Overlay] is required.
84100
final Widget debugRequiredFor;
101+
102+
/// The object supplied to the [CompositedTransformTarget] that wraps the text
103+
/// field.
85104
final LayerLink toolbarLayerLink;
105+
106+
/// The objects supplied to the [CompositedTransformTarget] that wraps the
107+
/// location of start selection handle.
86108
final LayerLink startHandleLayerLink;
109+
110+
/// The objects supplied to the [CompositedTransformTarget] that wraps the
111+
/// location of end selection handle.
87112
final LayerLink endHandleLayerLink;
113+
114+
/// The editable line in which the selected text is being displayed.
88115
final RenderEditor? renderObject;
116+
117+
/// Builds text selection handles and toolbar.
89118
final TextSelectionControls selectionCtrls;
119+
120+
/// The delegate for manipulating the current selection in the owning
121+
/// text field.
90122
final TextSelectionDelegate selectionDelegate;
123+
124+
/// Determines the way that drag start behavior is handled.
125+
///
126+
/// If set to [DragStartBehavior.start], handle drag behavior will
127+
/// begin upon the detection of a drag gesture. If set to
128+
/// [DragStartBehavior.down] it will begin when a down event is first
129+
/// detected.
130+
///
131+
/// In general, setting this to [DragStartBehavior.start] will make drag
132+
/// animation smoother and setting it to [DragStartBehavior.down] will make
133+
/// drag behavior feel slightly more reactive.
134+
///
135+
/// By default, the drag start behavior is [DragStartBehavior.start].
136+
///
137+
/// See also:
138+
///
139+
/// * [DragGestureRecognizer.dragStartBehavior],
140+
/// which gives an example for the different behaviors.
91141
final DragStartBehavior dragStartBehavior;
142+
143+
/// {@template flutter.widgets.textSelection.onSelectionHandleTapped}
144+
/// A callback that's invoked when a selection handle is tapped.
145+
///
146+
/// Both regular taps and long presses invoke this callback, but a drag
147+
/// gesture won't.
148+
/// {@endtemplate}
92149
final VoidCallback? onSelectionHandleTapped;
150+
151+
/// Maintains the status of the clipboard for determining if its contents can
152+
/// be pasted or not.
153+
///
154+
/// Useful because the actual value of the clipboard can only be checked
155+
/// asynchronously (see [Clipboard.getData]).
93156
final ClipboardStatusNotifier clipboardStatus;
94157
late AnimationController _toolbarController;
95158
List<OverlayEntry>? _handles;

0 commit comments

Comments
 (0)