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
7f4bb1ee
Unverified
Commit
7f4bb1ee
authored
Jan 27, 2021
by
Mouad Debbar
Committed by
GitHub
Jan 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the shortcuts temporary solution only on web (#74768)
parent
7c0300a3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
54 deletions
+62
-54
text_field.dart
packages/flutter/lib/src/cupertino/text_field.dart
+28
-23
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+27
-22
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+7
-9
No files found.
packages/flutter/lib/src/cupertino/text_field.dart
View file @
7f4bb1ee
...
...
@@ -4,7 +4,7 @@
import
'dart:ui'
as
ui
show
BoxHeightStyle
,
BoxWidthStyle
;
import
'package:flutter/foundation.dart'
show
defaultTargetPlatform
;
import
'package:flutter/foundation.dart'
show
defaultTargetPlatform
,
kIsWeb
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -1201,32 +1201,37 @@ class _CupertinoTextFieldState extends State<CupertinoTextField> with Restoratio
),
);
return
Shortcuts
(
shortcuts:
scrollShortcutOverrides
,
child:
Semantics
(
enabled:
enabled
,
onTap:
!
enabled
||
widget
.
readOnly
?
null
:
()
{
if
(!
controller
.
selection
.
isValid
)
{
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
}
_requestKeyboard
();
},
child:
IgnorePointer
(
ignoring:
!
enabled
,
child:
Container
(
decoration:
effectiveDecoration
,
child:
_selectionGestureDetectorBuilder
.
buildGestureDetector
(
behavior:
HitTestBehavior
.
translucent
,
child:
Align
(
alignment:
Alignment
(-
1.0
,
_textAlignVertical
.
y
),
widthFactor:
1.0
,
heightFactor:
1.0
,
child:
_addTextDependentAttachments
(
paddedEditable
,
textStyle
,
placeholderStyle
),
),
final
Widget
child
=
Semantics
(
enabled:
enabled
,
onTap:
!
enabled
||
widget
.
readOnly
?
null
:
()
{
if
(!
controller
.
selection
.
isValid
)
{
controller
.
selection
=
TextSelection
.
collapsed
(
offset:
controller
.
text
.
length
);
}
_requestKeyboard
();
},
child:
IgnorePointer
(
ignoring:
!
enabled
,
child:
Container
(
decoration:
effectiveDecoration
,
child:
_selectionGestureDetectorBuilder
.
buildGestureDetector
(
behavior:
HitTestBehavior
.
translucent
,
child:
Align
(
alignment:
Alignment
(-
1.0
,
_textAlignVertical
.
y
),
widthFactor:
1.0
,
heightFactor:
1.0
,
child:
_addTextDependentAttachments
(
paddedEditable
,
textStyle
,
placeholderStyle
),
),
),
),
),
);
if
(
kIsWeb
)
{
return
Shortcuts
(
shortcuts:
scrollShortcutOverrides
,
child:
child
,
);
}
return
child
;
}
}
packages/flutter/lib/src/material/text_field.dart
View file @
7f4bb1ee
...
...
@@ -1290,35 +1290,40 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
semanticsMaxValueLength
=
null
;
}
return
MouseRegion
(
child
=
MouseRegion
(
cursor:
effectiveMouseCursor
,
onEnter:
(
PointerEnterEvent
event
)
=>
_handleHover
(
true
),
onExit:
(
PointerExitEvent
event
)
=>
_handleHover
(
false
),
child:
Shortcuts
(
shortcuts:
scrollShortcutOverrides
,
child:
IgnorePointer
(
ignoring:
!
_isEnabled
,
child:
AnimatedBuilder
(
animation:
controller
,
// changes the _currentLength
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Semantics
(
maxValueLength:
semanticsMaxValueLength
,
currentValueLength:
_currentLength
,
onTap:
widget
.
readOnly
?
null
:
()
{
if
(!
_effectiveController
.
selection
.
isValid
)
_effectiveController
.
selection
=
TextSelection
.
collapsed
(
offset:
_effectiveController
.
text
.
length
);
_requestKeyboard
();
},
child:
child
,
);
},
child:
_selectionGestureDetectorBuilder
.
buildGestureDetector
(
behavior:
HitTestBehavior
.
translucent
,
child:
IgnorePointer
(
ignoring:
!
_isEnabled
,
child:
AnimatedBuilder
(
animation:
controller
,
// changes the _currentLength
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Semantics
(
maxValueLength:
semanticsMaxValueLength
,
currentValueLength:
_currentLength
,
onTap:
widget
.
readOnly
?
null
:
()
{
if
(!
_effectiveController
.
selection
.
isValid
)
_effectiveController
.
selection
=
TextSelection
.
collapsed
(
offset:
_effectiveController
.
text
.
length
);
_requestKeyboard
();
},
child:
child
,
),
);
},
child:
_selectionGestureDetectorBuilder
.
buildGestureDetector
(
behavior:
HitTestBehavior
.
translucent
,
child:
child
,
),
),
),
);
if
(
kIsWeb
)
{
return
Shortcuts
(
shortcuts:
scrollShortcutOverrides
,
child:
child
,
);
}
return
child
;
}
}
packages/flutter/lib/src/widgets/editable_text.dart
View file @
7f4bb1ee
...
...
@@ -58,15 +58,13 @@ const int _kObscureShowLatestCharCursorTicks = 3;
/// A map used to disable scrolling shortcuts in text fields.
///
/// This is a temporary fix for: https://github.com/flutter/flutter/issues/74191
final
Map
<
LogicalKeySet
,
Intent
>
scrollShortcutOverrides
=
kIsWeb
?
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
space
):
DoNothingAndStopPropagationIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
arrowUp
):
DoNothingAndStopPropagationIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
arrowDown
):
DoNothingAndStopPropagationIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
arrowLeft
):
DoNothingAndStopPropagationIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
arrowRight
):
DoNothingAndStopPropagationIntent
(),
}
:
<
LogicalKeySet
,
Intent
>{};
final
Map
<
LogicalKeySet
,
Intent
>
scrollShortcutOverrides
=
<
LogicalKeySet
,
Intent
>{
LogicalKeySet
(
LogicalKeyboardKey
.
space
):
DoNothingAndStopPropagationIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
arrowUp
):
DoNothingAndStopPropagationIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
arrowDown
):
DoNothingAndStopPropagationIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
arrowLeft
):
DoNothingAndStopPropagationIntent
(),
LogicalKeySet
(
LogicalKeyboardKey
.
arrowRight
):
DoNothingAndStopPropagationIntent
(),
};
/// A controller for an editable text field.
///
...
...
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