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
33e261c0
Unverified
Commit
33e261c0
authored
Nov 01, 2021
by
Tomasz Gucio
Committed by
GitHub
Nov 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update clipboard status on cut (#92167)
Cut now explicitly updates the clipboard status.
parent
88652122
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
82 additions
and
7 deletions
+82
-7
desktop_text_selection.dart
...ges/flutter/lib/src/cupertino/desktop_text_selection.dart
+1
-1
text_selection.dart
packages/flutter/lib/src/cupertino/text_selection.dart
+1
-1
desktop_text_selection.dart
...ages/flutter/lib/src/material/desktop_text_selection.dart
+1
-1
text_selection.dart
packages/flutter/lib/src/material/text_selection.dart
+1
-1
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+1
-1
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+2
-1
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+1
-1
text_selection_test.dart
packages/flutter/test/widgets/text_selection_test.dart
+74
-0
No files found.
packages/flutter/lib/src/cupertino/desktop_text_selection.dart
View file @
33e261c0
...
...
@@ -55,7 +55,7 @@ class _CupertinoDesktopTextSelectionControls extends TextSelectionControls {
clipboardStatus:
clipboardStatus
,
endpoints:
endpoints
,
globalEditableRegion:
globalEditableRegion
,
handleCut:
canCut
(
delegate
)
?
()
=>
handleCut
(
delegate
)
:
null
,
handleCut:
canCut
(
delegate
)
?
()
=>
handleCut
(
delegate
,
clipboardStatus
)
:
null
,
handleCopy:
canCopy
(
delegate
)
?
()
=>
handleCopy
(
delegate
,
clipboardStatus
)
:
null
,
handlePaste:
canPaste
(
delegate
)
?
()
=>
handlePaste
(
delegate
)
:
null
,
handleSelectAll:
canSelectAll
(
delegate
)
?
()
=>
handleSelectAll
(
delegate
)
:
null
,
...
...
packages/flutter/lib/src/cupertino/text_selection.dart
View file @
33e261c0
...
...
@@ -236,7 +236,7 @@ class CupertinoTextSelectionControls extends TextSelectionControls {
clipboardStatus:
clipboardStatus
,
endpoints:
endpoints
,
globalEditableRegion:
globalEditableRegion
,
handleCut:
canCut
(
delegate
)
?
()
=>
handleCut
(
delegate
)
:
null
,
handleCut:
canCut
(
delegate
)
?
()
=>
handleCut
(
delegate
,
clipboardStatus
)
:
null
,
handleCopy:
canCopy
(
delegate
)
?
()
=>
handleCopy
(
delegate
,
clipboardStatus
)
:
null
,
handlePaste:
canPaste
(
delegate
)
?
()
=>
handlePaste
(
delegate
)
:
null
,
handleSelectAll:
canSelectAll
(
delegate
)
?
()
=>
handleSelectAll
(
delegate
)
:
null
,
...
...
packages/flutter/lib/src/material/desktop_text_selection.dart
View file @
33e261c0
...
...
@@ -41,7 +41,7 @@ class _DesktopTextSelectionControls extends TextSelectionControls {
clipboardStatus:
clipboardStatus
,
endpoints:
endpoints
,
globalEditableRegion:
globalEditableRegion
,
handleCut:
canCut
(
delegate
)
?
()
=>
handleCut
(
delegate
)
:
null
,
handleCut:
canCut
(
delegate
)
?
()
=>
handleCut
(
delegate
,
clipboardStatus
)
:
null
,
handleCopy:
canCopy
(
delegate
)
?
()
=>
handleCopy
(
delegate
,
clipboardStatus
)
:
null
,
handlePaste:
canPaste
(
delegate
)
?
()
=>
handlePaste
(
delegate
)
:
null
,
handleSelectAll:
canSelectAll
(
delegate
)
?
()
=>
handleSelectAll
(
delegate
)
:
null
,
...
...
packages/flutter/lib/src/material/text_selection.dart
View file @
33e261c0
...
...
@@ -45,7 +45,7 @@ class MaterialTextSelectionControls extends TextSelectionControls {
endpoints:
endpoints
,
delegate:
delegate
,
clipboardStatus:
clipboardStatus
,
handleCut:
canCut
(
delegate
)
?
()
=>
handleCut
(
delegate
)
:
null
,
handleCut:
canCut
(
delegate
)
?
()
=>
handleCut
(
delegate
,
clipboardStatus
)
:
null
,
handleCopy:
canCopy
(
delegate
)
?
()
=>
handleCopy
(
delegate
,
clipboardStatus
)
:
null
,
handlePaste:
canPaste
(
delegate
)
?
()
=>
handlePaste
(
delegate
)
:
null
,
handleSelectAll:
canSelectAll
(
delegate
)
?
()
=>
handleSelectAll
(
delegate
)
:
null
,
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
33e261c0
...
...
@@ -2808,7 +2808,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
VoidCallback
?
_semanticsOnCut
(
TextSelectionControls
?
controls
)
{
return
widget
.
selectionEnabled
&&
cutEnabled
&&
_hasFocus
&&
controls
?.
canCut
(
this
)
==
true
?
()
=>
controls
!.
handleCut
(
this
)
?
()
=>
controls
!.
handleCut
(
this
,
_clipboardStatus
)
:
null
;
}
...
...
packages/flutter/lib/src/widgets/text_selection.dart
View file @
33e261c0
...
...
@@ -204,8 +204,9 @@ abstract class TextSelectionControls {
///
/// This is called by subclasses when their cut affordance is activated by
/// the user.
void
handleCut
(
TextSelectionDelegate
delegate
)
{
void
handleCut
(
TextSelectionDelegate
delegate
,
ClipboardStatusNotifier
?
clipboardStatus
)
{
delegate
.
cutSelection
(
SelectionChangedCause
.
toolbar
);
clipboardStatus
?.
update
();
}
/// Call [TextSelectionDelegate.copySelection] to copy current selection.
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
33e261c0
...
...
@@ -8724,7 +8724,7 @@ class MockTextSelectionControls extends Fake implements TextSelectionControls {
}
@override
void
handleCut
(
TextSelectionDelegate
delegate
)
{
void
handleCut
(
TextSelectionDelegate
delegate
,
ClipboardStatusNotifier
?
clipboardStatus
)
{
cutCount
+=
1
;
}
...
...
packages/flutter/test/widgets/text_selection_test.dart
View file @
33e261c0
...
...
@@ -759,6 +759,28 @@ void main() {
});
});
});
group
(
'TextSelectionControls'
,
()
{
test
(
'ClipboardStatusNotifier is updated on handleCut'
,
()
async
{
final
FakeClipboardStatusNotifier
clipboardStatus
=
FakeClipboardStatusNotifier
();
final
FakeTextSelectionDelegate
delegate
=
FakeTextSelectionDelegate
();
final
CustomTextSelectionControls
textSelectionControls
=
CustomTextSelectionControls
();
expect
(
clipboardStatus
.
updateCalled
,
false
);
textSelectionControls
.
handleCut
(
delegate
,
clipboardStatus
);
expect
(
clipboardStatus
.
updateCalled
,
true
);
});
test
(
'ClipboardStatusNotifier is updated on handleCopy'
,
()
async
{
final
FakeClipboardStatusNotifier
clipboardStatus
=
FakeClipboardStatusNotifier
();
final
FakeTextSelectionDelegate
delegate
=
FakeTextSelectionDelegate
();
final
CustomTextSelectionControls
textSelectionControls
=
CustomTextSelectionControls
();
expect
(
clipboardStatus
.
updateCalled
,
false
);
textSelectionControls
.
handleCopy
(
delegate
,
clipboardStatus
);
expect
(
clipboardStatus
.
updateCalled
,
true
);
});
});
}
class
FakeTextSelectionGestureDetectorBuilderDelegate
implements
TextSelectionGestureDetectorBuilderDelegate
{
...
...
@@ -872,3 +894,55 @@ class FakeRenderEditable extends RenderEditable {
selectWordCalled
=
true
;
}
}
class
CustomTextSelectionControls
extends
TextSelectionControls
{
@override
Widget
buildHandle
(
BuildContext
context
,
TextSelectionHandleType
type
,
double
textLineHeight
,
[
VoidCallback
?
onTap
,
double
?
startGlyphHeight
,
double
?
endGlyphHeight
])
{
throw
UnimplementedError
();
}
@override
Widget
buildToolbar
(
BuildContext
context
,
Rect
globalEditableRegion
,
double
textLineHeight
,
Offset
position
,
List
<
TextSelectionPoint
>
endpoints
,
TextSelectionDelegate
delegate
,
ClipboardStatusNotifier
clipboardStatus
,
Offset
?
lastSecondaryTapDownPosition
,
)
{
throw
UnimplementedError
();
}
@override
Offset
getHandleAnchor
(
TextSelectionHandleType
type
,
double
textLineHeight
,
[
double
?
startGlyphHeight
,
double
?
endGlyphHeight
])
{
throw
UnimplementedError
();
}
@override
Size
getHandleSize
(
double
textLineHeight
)
{
throw
UnimplementedError
();
}
}
class
FakeClipboardStatusNotifier
extends
ClipboardStatusNotifier
{
FakeClipboardStatusNotifier
()
:
super
(
value:
ClipboardStatus
.
unknown
);
@override
bool
get
disposed
=>
false
;
bool
updateCalled
=
false
;
@override
Future
<
void
>
update
()
async
{
updateCalled
=
true
;
}
}
class
FakeTextSelectionDelegate
extends
Fake
implements
TextSelectionDelegate
{
@override
void
cutSelection
(
SelectionChangedCause
cause
)
{
}
@override
void
copySelection
(
SelectionChangedCause
cause
)
{
}
}
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