Unverified Commit 0f7f08d5 authored by Justin McCandless's avatar Justin McCandless Committed by GitHub

Floating cursor docs (#133002)

Explains what a "floating cursor" is in the docs.
parent a98e43a8
......@@ -886,6 +886,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
/// Typically this would be set to [CupertinoColors.inactiveGray].
///
/// If this is null, the background cursor is not painted.
///
/// See also:
///
/// * [FloatingCursorDragState], which explains the floating cursor feature
/// in detail.
Color? get backgroundCursorColor => _caretPainter.backgroundCursorColor;
set backgroundCursorColor(Color? value) {
_caretPainter.backgroundCursorColor = value;
......@@ -1181,6 +1186,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
/// moving the floating cursor.
///
/// Defaults to a padding with left, top and right set to 4, bottom to 5.
///
/// See also:
///
/// * [FloatingCursorDragState], which explains the floating cursor feature
/// in detail.
EdgeInsets floatingCursorAddedMargin;
bool _floatingCursorOn = false;
......@@ -2381,6 +2391,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
}
/// Returns the position within the text field closest to the raw cursor offset.
///
/// See also:
///
/// * [FloatingCursorDragState], which explains the floating cursor feature
/// in detail.
Offset calculateBoundedFloatingCursorOffset(Offset rawCursorOffset, {bool? shouldResetOrigin}) {
Offset deltaPosition = Offset.zero;
final double topBound = -floatingCursorAddedMargin.top;
......@@ -2440,6 +2455,11 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
/// Sets the screen position of the floating cursor and the text position
/// closest to the cursor.
///
/// See also:
///
/// * [FloatingCursorDragState], which explains the floating cursor feature
/// in detail.
void setFloatingCursor(FloatingCursorDragState state, Offset boundedOffset, TextPosition lastTextPosition, { double? resetLerpValue }) {
if (state == FloatingCursorDragState.End) {
_relativeOrigin = Offset.zero;
......
......@@ -721,10 +721,34 @@ TextAffinity? _toTextAffinity(String? affinity) {
return null;
}
/// A floating cursor state the user has induced by force pressing an iOS
/// keyboard.
/// The state of a "floating cursor" drag on an iOS soft keyboard.
///
/// The "floating cursor" cursor-positioning mode is an iOS feature used to
/// precisely position the caret in some editable text using certain touch
/// gestures. As an example, when the user long-presses the spacebar on the iOS
/// virtual keyboard, iOS enters floating cursor mode where the whole keyboard
/// becomes a trackpad. In this mode, there are two visible cursors. One, the
/// floating cursor, hovers over the text, following the user's horizontal
/// movements exactly and snapping to lines vertically. The other, the
/// placeholder cursor, is a "shadow" that also snaps to the actual location
/// where the cursor will go horizontally when the user releases the trackpad.
///
/// The floating cursor renders over the text field, while the placeholder
/// cursor is a faint shadow of the cursor rendered in the text field in the
/// location between characters where the cursor will drop into when released.
/// The placeholder cursor is a faint vertical bar, while the floating cursor
/// has the same appearance as a normal cursor (a blue vertical bar).
///
/// This feature works out-of-the-box with Flutter. Support is built into
/// [EditableText].
///
/// See also:
///
/// * [EditableText.backgroundCursorColor], which configures the color of the
/// placeholder cursor while the floating cursor is being dragged.
enum FloatingCursorDragState {
/// A user has just activated a floating cursor.
/// A user has just activated a floating cursor by long pressing on the
/// spacebar.
Start,
/// A user is dragging a floating cursor.
......@@ -736,6 +760,11 @@ enum FloatingCursorDragState {
}
/// The current state and position of the floating cursor.
///
/// See also:
///
/// * [FloatingCursorDragState], which explains the floating cursor feature in
/// detail.
class RawFloatingCursorPoint {
/// Creates information for setting the position and state of a floating
/// cursor.
......@@ -1151,6 +1180,11 @@ mixin TextInputClient {
void performPrivateCommand(String action, Map<String, dynamic> data);
/// Updates the floating cursor position and state.
///
/// See also:
///
/// * [FloatingCursorDragState], which explains the floating cursor feature
/// in detail.
void updateFloatingCursor(RawFloatingCursorPoint point);
/// Requests that this client display a prompt rectangle for the given text range,
......
......@@ -1093,6 +1093,11 @@ class EditableText extends StatefulWidget {
/// while rendering the floating cursor.
///
/// Typically this would be set to [CupertinoColors.inactiveGray].
///
/// See also:
///
/// * [FloatingCursorDragState], which explains the floating cursor feature
/// in detail.
final Color backgroundCursorColor;
/// {@template flutter.widgets.editableText.maxLines}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment