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
15ceca93
Unverified
Commit
15ceca93
authored
Jan 23, 2024
by
Ian Hickson
Committed by
GitHub
Jan 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable contextMenuBuilder in the absence of selectionControls (#141810)
parent
38be1376
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
5 deletions
+49
-5
events.dart
packages/flutter/lib/src/gestures/events.dart
+2
-2
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+0
-1
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+1
-1
text_selection_test.dart
packages/flutter/test/widgets/text_selection_test.dart
+46
-1
No files found.
packages/flutter/lib/src/gestures/events.dart
View file @
15ceca93
...
...
@@ -39,7 +39,7 @@ const int kPrimaryButton = 0x01;
///
/// It is equivalent to:
///
/// * [kPrimaryStylusButton]: The stylus
contacts the scree
n.
/// * [kPrimaryStylusButton]: The stylus
' primary butto
n.
/// * [kSecondaryMouseButton]: The secondary mouse button.
///
/// See also:
...
...
@@ -97,7 +97,7 @@ const int kPrimaryStylusButton = kSecondaryButton;
///
/// It is equivalent to:
///
/// * [kMiddleMouseButton]: The tertiary mouse
B
utton.
/// * [kMiddleMouseButton]: The tertiary mouse
b
utton.
/// * [kSecondaryStylusButton]: The secondary button on a stylus. This is considered
/// a tertiary button as the primary button of a stylus already corresponds to a
/// "secondary operation" (where stylus contact is the primary operation).
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
15ceca93
...
...
@@ -4320,7 +4320,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
/// Toggles the visibility of the toolbar.
void
toggleToolbar
([
bool
hideHandles
=
true
])
{
final
TextSelectionOverlay
selectionOverlay
=
_selectionOverlay
??=
_createSelectionOverlay
();
if
(
selectionOverlay
.
toolbarIsVisible
)
{
hideToolbar
(
hideHandles
);
}
else
{
...
...
packages/flutter/lib/src/widgets/text_selection.dart
View file @
15ceca93
...
...
@@ -448,7 +448,7 @@ class TextSelectionOverlay {
void
showToolbar
()
{
_updateSelectionOverlay
();
if
(
selectionControls
is
!
TextSelectionHandleControls
)
{
if
(
selectionControls
!=
null
&&
selectionControls
is
!
TextSelectionHandleControls
)
{
_selectionOverlay
.
showToolbar
();
return
;
}
...
...
packages/flutter/test/widgets/text_selection_test.dart
View file @
15ceca93
...
...
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
show
ValueListenable
,
defaultTargetPlatform
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -1781,6 +1781,51 @@ void main() {
);
});
});
testWidgets
(
'Context menus'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'You make wine from sour grapes'
,
);
addTearDown
(
controller
.
dispose
);
final
GlobalKey
<
EditableTextState
>
editableTextKey
=
GlobalKey
<
EditableTextState
>();
final
FakeTextSelectionGestureDetectorBuilderDelegate
delegate
=
FakeTextSelectionGestureDetectorBuilderDelegate
(
editableTextKey:
editableTextKey
,
forcePressEnabled:
false
,
selectionEnabled:
true
,
);
final
TextSelectionGestureDetectorBuilder
provider
=
TextSelectionGestureDetectorBuilder
(
delegate:
delegate
);
final
FocusNode
focusNode
=
FocusNode
();
addTearDown
(
focusNode
.
dispose
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
provider
.
buildGestureDetector
(
behavior:
HitTestBehavior
.
translucent
,
child:
EditableText
(
key:
editableTextKey
,
controller:
controller
,
focusNode:
focusNode
,
backgroundCursorColor:
Colors
.
white
,
cursorColor:
Colors
.
white
,
style:
const
TextStyle
(),
contextMenuBuilder:
(
BuildContext
context
,
EditableTextState
editableTextState
,
)
{
return
const
Placeholder
();
},
),
),
),
);
final
Offset
position
=
textOffsetToPosition
(
tester
,
0
);
expect
(
find
.
byType
(
Placeholder
),
findsNothing
);
await
tester
.
tapAt
(
position
,
buttons:
kSecondaryMouseButton
,
kind:
PointerDeviceKind
.
mouse
);
await
tester
.
pump
();
expect
(
find
.
byType
(
Placeholder
),
findsOneWidget
);
},
skip:
kIsWeb
);
// [intended] On web, we use native context menus for text fields.
}
class
FakeTextSelectionGestureDetectorBuilderDelegate
implements
TextSelectionGestureDetectorBuilderDelegate
{
...
...
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