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
72df4801
Unverified
Commit
72df4801
authored
Jan 14, 2022
by
Hans Muller
Committed by
GitHub
Jan 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Land Set "basic" mouse cursor for disabled buttons, PR #89346 (#96561)
parent
c24b2c3c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
246 additions
and
10 deletions
+246
-10
elevated_button.dart
packages/flutter/lib/src/material/elevated_button.dart
+2
-2
icon_button.dart
packages/flutter/lib/src/material/icon_button.dart
+2
-2
outlined_button.dart
packages/flutter/lib/src/material/outlined_button.dart
+2
-2
text_button.dart
packages/flutter/lib/src/material/text_button.dart
+2
-2
elevated_button_test.dart
packages/flutter/test/material/elevated_button_test.dart
+79
-0
icon_button_test.dart
packages/flutter/test/material/icon_button_test.dart
+2
-2
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+79
-0
text_button_test.dart
packages/flutter/test/material/text_button_test.dart
+78
-0
No files found.
packages/flutter/lib/src/material/elevated_button.dart
View file @
72df4801
...
...
@@ -255,7 +255,7 @@ class ElevatedButton extends ButtonStyleButton {
/// * `side` - null
/// * `shape` - RoundedRectangleBorder(borderRadius: BorderRadius.circular(4))
/// * `mouseCursor`
/// * disabled - SystemMouseCursors.
forbidden
/// * disabled - SystemMouseCursors.
basic
/// * others - SystemMouseCursors.click
/// * `visualDensity` - theme.visualDensity
/// * `tapTargetSize` - theme.materialTapTargetSize
...
...
@@ -300,7 +300,7 @@ class ElevatedButton extends ButtonStyleButton {
maximumSize:
Size
.
infinite
,
shape:
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
4
))),
enabledMouseCursor:
SystemMouseCursors
.
click
,
disabledMouseCursor:
SystemMouseCursors
.
forbidden
,
disabledMouseCursor:
SystemMouseCursors
.
basic
,
visualDensity:
theme
.
visualDensity
,
tapTargetSize:
theme
.
materialTapTargetSize
,
animationDuration:
kThemeChangeDuration
,
...
...
packages/flutter/lib/src/material/icon_button.dart
View file @
72df4801
...
...
@@ -256,7 +256,7 @@ class IconButton extends StatelessWidget {
/// {@macro flutter.material.RawMaterialButton.mouseCursor}
///
/// If set to null, will default to
/// - [SystemMouseCursors.
forbidden
], if [onPressed] is null
/// - [SystemMouseCursors.
basic
], if [onPressed] is null
/// - [SystemMouseCursors.click], otherwise
final
MouseCursor
?
mouseCursor
;
...
...
@@ -357,7 +357,7 @@ class IconButton extends StatelessWidget {
autofocus:
autofocus
,
canRequestFocus:
onPressed
!=
null
,
onTap:
onPressed
,
mouseCursor:
mouseCursor
??
(
onPressed
==
null
?
SystemMouseCursors
.
forbidden
:
SystemMouseCursors
.
click
),
mouseCursor:
mouseCursor
??
(
onPressed
==
null
?
SystemMouseCursors
.
basic
:
SystemMouseCursors
.
click
),
enableFeedback:
enableFeedback
,
focusColor:
focusColor
??
theme
.
focusColor
,
hoverColor:
hoverColor
??
theme
.
hoverColor
,
...
...
packages/flutter/lib/src/material/outlined_button.dart
View file @
72df4801
...
...
@@ -240,7 +240,7 @@ class OutlinedButton extends ButtonStyleButton {
/// * `side` - BorderSide(width: 1, color: Theme.colorScheme.onSurface(0.12))
/// * `shape` - RoundedRectangleBorder(borderRadius: BorderRadius.circular(4))
/// * `mouseCursor`
/// * disabled - SystemMouseCursors.
forbidden
/// * disabled - SystemMouseCursors.
basic
/// * others - SystemMouseCursors.click
/// * `visualDensity` - theme.visualDensity
/// * `tapTargetSize` - theme.materialTapTargetSize
...
...
@@ -275,7 +275,7 @@ class OutlinedButton extends ButtonStyleButton {
),
shape:
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
4
))),
enabledMouseCursor:
SystemMouseCursors
.
click
,
disabledMouseCursor:
SystemMouseCursors
.
forbidden
,
disabledMouseCursor:
SystemMouseCursors
.
basic
,
visualDensity:
theme
.
visualDensity
,
tapTargetSize:
theme
.
materialTapTargetSize
,
animationDuration:
kThemeChangeDuration
,
...
...
packages/flutter/lib/src/material/text_button.dart
View file @
72df4801
...
...
@@ -244,7 +244,7 @@ class TextButton extends ButtonStyleButton {
/// * `side` - null
/// * `shape` - RoundedRectangleBorder(borderRadius: BorderRadius.circular(4))
/// * `mouseCursor`
/// * disabled - SystemMouseCursors.
forbidden
/// * disabled - SystemMouseCursors.
basic
/// * others - SystemMouseCursors.click
/// * `visualDensity` - theme.visualDensity
/// * `tapTargetSize` - theme.materialTapTargetSize
...
...
@@ -288,7 +288,7 @@ class TextButton extends ButtonStyleButton {
maximumSize:
Size
.
infinite
,
shape:
const
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
4
))),
enabledMouseCursor:
SystemMouseCursors
.
click
,
disabledMouseCursor:
SystemMouseCursors
.
forbidden
,
disabledMouseCursor:
SystemMouseCursors
.
basic
,
visualDensity:
theme
.
visualDensity
,
tapTargetSize:
theme
.
materialTapTargetSize
,
animationDuration:
kThemeChangeDuration
,
...
...
packages/flutter/test/material/elevated_button_test.dart
View file @
72df4801
...
...
@@ -1418,6 +1418,85 @@ void main() {
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
ElevatedButton
,
'200x200'
)),
const
Size
(
200
,
200
));
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
ElevatedButton
,
'200,200'
)),
const
Size
(
200
,
200
));
});
testWidgets
(
'ElevatedButton changes mouse cursor when hovered'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
enabledMouseCursor:
SystemMouseCursors
.
text
,
disabledMouseCursor:
SystemMouseCursors
.
grab
,
),
onPressed:
()
{},
child:
const
Text
(
'button'
),
),
),
),
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
Offset
.
zero
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
// Test cursor when disabled
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
ElevatedButton
(
style:
ElevatedButton
.
styleFrom
(
enabledMouseCursor:
SystemMouseCursors
.
text
,
disabledMouseCursor:
SystemMouseCursors
.
grab
,
),
onPressed:
null
,
child:
const
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
grab
);
// Test default cursor
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
ElevatedButton
(
onPressed:
()
{},
child:
const
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
// Test default cursor when disabled
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
ElevatedButton
(
onPressed:
null
,
child:
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
}
TextStyle
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
...
...
packages/flutter/test/material/icon_button_test.dart
View file @
72df4801
...
...
@@ -793,7 +793,7 @@ void main() {
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
});
testWidgets
(
'disabled IconButton has
forbidden
mouse cursor'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'disabled IconButton has
basic
mouse cursor'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Material
(
child:
Directionality
(
...
...
@@ -814,7 +814,7 @@ void main() {
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
forbidden
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
testWidgets
(
'IconButton.mouseCursor overrides implicit setting of mouse cursor'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
72df4801
...
...
@@ -1593,6 +1593,85 @@ void main() {
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
OutlinedButton
,
'200x200'
)),
const
Size
(
200
,
200
));
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
OutlinedButton
,
'200,200'
)),
const
Size
(
200
,
200
));
});
testWidgets
(
'OutlinedButton changes mouse cursor when hovered'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
OutlinedButton
(
style:
OutlinedButton
.
styleFrom
(
enabledMouseCursor:
SystemMouseCursors
.
text
,
disabledMouseCursor:
SystemMouseCursors
.
grab
,
),
onPressed:
()
{},
child:
const
Text
(
'button'
),
),
),
),
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
Offset
.
zero
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
// Test cursor when disabled
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
OutlinedButton
(
style:
OutlinedButton
.
styleFrom
(
enabledMouseCursor:
SystemMouseCursors
.
text
,
disabledMouseCursor:
SystemMouseCursors
.
grab
,
),
onPressed:
null
,
child:
const
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
grab
);
// Test default cursor
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
OutlinedButton
(
onPressed:
()
{},
child:
const
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
// Test default cursor when disabled
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
OutlinedButton
(
onPressed:
null
,
child:
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
}
PhysicalModelLayer
_findPhysicalLayer
(
Element
element
)
{
...
...
packages/flutter/test/material/text_button_test.dart
View file @
72df4801
...
...
@@ -1391,6 +1391,84 @@ void main() {
expect
(
tester
.
getSize
(
find
.
widgetWithText
(
TextButton
,
'200,200'
)),
const
Size
(
200
,
200
));
});
testWidgets
(
'TextButton changes mouse cursor when hovered'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
TextButton
(
style:
TextButton
.
styleFrom
(
enabledMouseCursor:
SystemMouseCursors
.
text
,
disabledMouseCursor:
SystemMouseCursors
.
grab
,
),
onPressed:
()
{},
child:
const
Text
(
'button'
),
),
),
),
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
Offset
.
zero
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
// Test cursor when disabled
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
TextButton
(
style:
TextButton
.
styleFrom
(
enabledMouseCursor:
SystemMouseCursors
.
text
,
disabledMouseCursor:
SystemMouseCursors
.
grab
,
),
onPressed:
null
,
child:
const
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
grab
);
// Test default cursor
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
TextButton
(
onPressed:
()
{},
child:
const
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
// Test default cursor when disabled
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
cursor:
SystemMouseCursors
.
forbidden
,
child:
TextButton
(
onPressed:
null
,
child:
Text
(
'button'
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
}
TextStyle
?
_iconStyle
(
WidgetTester
tester
,
IconData
icon
)
{
...
...
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