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
72931955
Commit
72931955
authored
Jan 21, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1332 from abarth/no_autofocus
Don't autofocus Input widgets by default
parents
740b6122
f176ed27
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
6 deletions
+29
-6
meal.dart
examples/fitness/lib/meal.dart
+1
-0
measurement.dart
examples/fitness/lib/measurement.dart
+1
-0
settings.dart
examples/fitness/lib/settings.dart
+1
-0
stock_home.dart
examples/stocks/lib/stock_home.dart
+2
-0
input.dart
packages/flutter/lib/src/material/input.dart
+19
-1
focus.dart
packages/flutter/lib/src/widgets/focus.dart
+4
-4
focus_test.dart
packages/flutter/test/widget/focus_test.dart
+1
-1
No files found.
examples/fitness/lib/meal.dart
View file @
72931955
...
...
@@ -89,6 +89,7 @@ class MealFragmentState extends State<MealFragment> {
new
Text
(
meal
.
displayDate
),
new
Input
(
key:
descriptionKey
,
autofocus:
true
,
placeholder:
'Describe meal'
,
onChanged:
_handleDescriptionChanged
),
...
...
examples/fitness/lib/measurement.dart
View file @
72931955
...
...
@@ -141,6 +141,7 @@ class MeasurementFragmentState extends State<MeasurementFragment> {
),
new
Input
(
key:
weightKey
,
autofocus:
true
,
placeholder:
'Enter weight'
,
keyboardType:
KeyboardType
.
number
,
onChanged:
_handleWeightChanged
...
...
examples/fitness/lib/settings.dart
View file @
72931955
...
...
@@ -62,6 +62,7 @@ class SettingsFragmentState extends State<SettingsFragment> {
title:
new
Text
(
"Goal Weight"
),
content:
new
Input
(
key:
weightGoalKey
,
autofocus:
true
,
placeholder:
'Goal weight in lbs'
,
keyboardType:
KeyboardType
.
number
,
onChanged:
_handleGoalWeightChanged
...
...
examples/stocks/lib/stock_home.dart
View file @
72931955
...
...
@@ -236,6 +236,7 @@ class StockHomeState extends State<StockHome> {
),
center:
new
Input
(
key:
searchFieldKey
,
autofocus:
true
,
placeholder:
'Search stocks'
,
onChanged:
_handleSearchQueryChanged
),
...
...
@@ -252,6 +253,7 @@ class StockHomeState extends State<StockHome> {
children:
<
Widget
>[
new
Input
(
key:
companyNameKey
,
autofocus:
true
,
placeholder:
'Company Name'
),
]
...
...
packages/flutter/lib/src/material/input.dart
View file @
72931955
...
...
@@ -12,6 +12,7 @@ import 'theme.dart';
export
'package:flutter/rendering.dart'
show
ValueChanged
;
export
'package:flutter/services.dart'
show
KeyboardType
;
/// A material design text input widget.
class
Input
extends
Scrollable
{
Input
({
GlobalKey
key
,
...
...
@@ -19,6 +20,7 @@ class Input extends Scrollable {
this
.
placeholder
,
this
.
hideText
:
false
,
this
.
isDense
:
false
,
this
.
autofocus
:
false
,
this
.
onChanged
,
this
.
keyboardType
:
KeyboardType
.
text
,
this
.
onSubmitted
...
...
@@ -30,12 +32,28 @@ class Input extends Scrollable {
assert
(
key
!=
null
);
}
/// Initial editable text for the widget.
final
String
initialValue
;
/// The type of keyboard to use for editing the text.
final
KeyboardType
keyboardType
;
/// Hint text to show when the widget doesn't contain editable text.
final
String
placeholder
;
/// Whether to hide the text being edited (e.g., for passwords).
final
bool
hideText
;
/// Whether the input widget is part of a dense form (i.e., uses less vertical space).
final
bool
isDense
;
/// Whether this input widget should focus itself is nothing else is already focused.
final
bool
autofocus
;
/// Called when the text being edited changes.
final
ValueChanged
<
String
>
onChanged
;
/// Called when the user indicates that they are done editing the text in the widget.
final
ValueChanged
<
String
>
onSubmitted
;
InputState
createState
()
=>
new
InputState
();
...
...
@@ -79,7 +97,7 @@ class InputState extends ScrollableState<Input> {
Widget
buildContent
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
ThemeData
themeData
=
Theme
.
of
(
context
);
bool
focused
=
Focus
.
at
(
context
);
bool
focused
=
Focus
.
at
(
context
,
autofocus:
config
.
autofocus
);
if
(
focused
&&
!
_keyboardHandle
.
attached
)
{
_keyboardHandle
=
keyboard
.
show
(
_editableValue
.
stub
,
config
.
keyboardType
);
...
...
packages/flutter/lib/src/widgets/focus.dart
View file @
72931955
...
...
@@ -84,7 +84,7 @@ class Focus extends StatefulComponent {
static
GlobalKey
debugOnlyFocusedKey
;
static
bool
at
(
BuildContext
context
,
{
bool
autofocus:
tru
e
})
{
static
bool
at
(
BuildContext
context
,
{
bool
autofocus:
fals
e
})
{
assert
(
context
!=
null
);
assert
(
context
.
widget
!=
null
);
assert
(
context
.
widget
.
key
!=
null
);
...
...
@@ -109,7 +109,7 @@ class Focus extends StatefulComponent {
return
true
;
}
static
bool
_atScope
(
BuildContext
context
,
{
bool
autofocus:
tru
e
})
{
static
bool
_atScope
(
BuildContext
context
,
{
bool
autofocus:
fals
e
})
{
assert
(
context
!=
null
);
assert
(
context
.
widget
!=
null
);
assert
(
context
.
widget
is
Focus
);
...
...
@@ -126,7 +126,7 @@ class Focus extends StatefulComponent {
/// Focuses a particular widget, identified by its GlobalKey.
/// The widget must be in the widget tree.
///
///
/// Don't call moveTo() from your build() functions, it's intended to be
/// called from event listeners, e.g. in response to a finger tap or tab key.
static
void
moveTo
(
GlobalKey
key
)
{
...
...
@@ -138,7 +138,7 @@ class Focus extends StatefulComponent {
/// Focuses a particular focus scope, identified by its GlobalKey. The widget
/// must be in the widget tree.
///
///
/// Don't call moveScopeTo() from your build() functions, it's intended to be
/// called from event listeners, e.g. in response to a finger tap or tab key.
static
void
moveScopeTo
(
GlobalKey
key
)
{
...
...
packages/flutter/test/widget/focus_test.dart
View file @
72931955
...
...
@@ -11,7 +11,7 @@ class TestFocusable extends StatelessComponent {
final
String
no
;
final
String
yes
;
Widget
build
(
BuildContext
context
)
{
bool
focused
=
Focus
.
at
(
context
);
bool
focused
=
Focus
.
at
(
context
,
autofocus:
true
);
return
new
GestureDetector
(
onTap:
()
{
Focus
.
moveTo
(
key
);
},
child:
new
Text
(
focused
?
yes
:
no
)
...
...
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