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
f6747dfa
Unverified
Commit
f6747dfa
authored
May 14, 2021
by
Justin Hutchins
Committed by
GitHub
May 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change cursor when hovering on DropdownButton (#80567)
parent
5bc34890
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
4 deletions
+74
-4
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+15
-4
dropdown_test.dart
packages/flutter/test/material/dropdown_test.dart
+59
-0
No files found.
packages/flutter/lib/src/material/dropdown.dart
View file @
f6747dfa
...
@@ -19,6 +19,7 @@ import 'ink_well.dart';
...
@@ -19,6 +19,7 @@ import 'ink_well.dart';
import
'input_decorator.dart'
;
import
'input_decorator.dart'
;
import
'material.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
import
'material_localizations.dart'
;
import
'material_state.dart'
;
import
'scrollbar.dart'
;
import
'scrollbar.dart'
;
import
'shadows.dart'
;
import
'shadows.dart'
;
import
'theme.dart'
;
import
'theme.dart'
;
...
@@ -1501,6 +1502,13 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
...
@@ -1501,6 +1502,13 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
);
);
}
}
final
MouseCursor
effectiveMouseCursor
=
MaterialStateProperty
.
resolveAs
<
MouseCursor
>(
MaterialStateMouseCursor
.
clickable
,
<
MaterialState
>{
if
(!
_enabled
)
MaterialState
.
disabled
,
},
);
return
Semantics
(
return
Semantics
(
button:
true
,
button:
true
,
child:
Actions
(
child:
Actions
(
...
@@ -1509,6 +1517,8 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
...
@@ -1509,6 +1517,8 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
canRequestFocus:
_enabled
,
canRequestFocus:
_enabled
,
focusNode:
focusNode
,
focusNode:
focusNode
,
autofocus:
widget
.
autofocus
,
autofocus:
widget
.
autofocus
,
child:
MouseRegion
(
cursor:
effectiveMouseCursor
,
child:
GestureDetector
(
child:
GestureDetector
(
onTap:
_enabled
?
_handleTap
:
null
,
onTap:
_enabled
?
_handleTap
:
null
,
behavior:
HitTestBehavior
.
opaque
,
behavior:
HitTestBehavior
.
opaque
,
...
@@ -1516,6 +1526,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
...
@@ -1516,6 +1526,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
),
),
),
),
),
),
),
);
);
}
}
}
}
...
...
packages/flutter/test/material/dropdown_test.dart
View file @
f6747dfa
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
import
'dart:ui'
show
window
;
import
'dart:ui'
show
window
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
...
@@ -3390,4 +3391,62 @@ void main() {
...
@@ -3390,4 +3391,62 @@ void main() {
expect
(
feedback
.
hapticCount
,
0
);
expect
(
feedback
.
hapticCount
,
0
);
});
});
});
});
testWidgets
(
'DropdownButton changes mouse cursor when hovered'
,
(
WidgetTester
tester
)
async
{
const
Key
key
=
Key
(
'testDropdownButton'
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
DropdownButton
<
String
>(
key:
key
,
onChanged:
(
String
?
newValue
)
{},
items:
<
String
>[
'One'
,
'Two'
,
'Three'
,
'Four'
]
.
map
<
DropdownMenuItem
<
String
>>((
String
value
)
{
return
DropdownMenuItem
<
String
>(
value:
value
,
child:
Text
(
value
),
);
}).
toList
()
),
),
),
);
final
Finder
dropdownButtonFinder
=
find
.
byKey
(
key
);
final
Offset
onDropdownButton
=
tester
.
getCenter
(
dropdownButtonFinder
);
final
Offset
offDropdownButton
=
tester
.
getBottomRight
(
dropdownButtonFinder
)
+
const
Offset
(
1
,
1
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
onDropdownButton
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
await
gesture
.
moveTo
(
offDropdownButton
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
// Test that mouse cursor doesn't change when button is disabled
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
DropdownButton
<
String
>(
key:
key
,
items:
<
String
>[
'One'
,
'Two'
,
'Three'
,
'Four'
]
.
map
<
DropdownMenuItem
<
String
>>((
String
value
)
{
return
DropdownMenuItem
<
String
>(
value:
value
,
child:
Text
(
value
),
);
}).
toList
()
),
),
),
);
await
gesture
.
moveTo
(
onDropdownButton
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
await
gesture
.
moveTo
(
offDropdownButton
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
}
}
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