Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0f7f08d5
Unverified
Commit
0f7f08d5
authored
Jan 22, 2024
by
Justin McCandless
Committed by
GitHub
Jan 22, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Floating cursor docs (#133002)
Explains what a "floating cursor" is in the docs.
parent
a98e43a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
3 deletions
+62
-3
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+20
-0
text_input.dart
packages/flutter/lib/src/services/text_input.dart
+37
-3
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+5
-0
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
0f7f08d5
...
...
@@ -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
;
...
...
packages/flutter/lib/src/services/text_input.dart
View file @
0f7f08d5
...
...
@@ -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,
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
0f7f08d5
...
...
@@ -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}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment