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
0a178f85
Unverified
Commit
0a178f85
authored
Apr 12, 2022
by
Taha Tesser
Committed by
GitHub
Apr 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
`CupertinoContextMenu`/`ContextMenuAction`: Add clickable cursor for web (#99519)
parent
6def1596
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
47 deletions
+118
-47
context_menu.dart
packages/flutter/lib/src/cupertino/context_menu.dart
+15
-11
context_menu_action.dart
packages/flutter/lib/src/cupertino/context_menu_action.dart
+40
-36
context_menu_action_test.dart
...ages/flutter/test/cupertino/context_menu_action_test.dart
+28
-0
context_menu_test.dart
packages/flutter/test/cupertino/context_menu_test.dart
+35
-0
No files found.
packages/flutter/lib/src/cupertino/context_menu.dart
View file @
0a178f85
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
import
'dart:ui'
as
ui
;
import
'dart:ui'
as
ui
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
show
kMinFlingVelocity
,
kLongPressTimeout
;
import
'package:flutter/gestures.dart'
show
kMinFlingVelocity
,
kLongPressTimeout
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
...
@@ -367,7 +368,9 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
...
@@ -367,7 +368,9 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
GestureDetector
(
return
MouseRegion
(
cursor:
kIsWeb
?
SystemMouseCursors
.
click
:
MouseCursor
.
defer
,
child:
GestureDetector
(
onTapCancel:
_onTapCancel
,
onTapCancel:
_onTapCancel
,
onTapDown:
_onTapDown
,
onTapDown:
_onTapDown
,
onTapUp:
_onTapUp
,
onTapUp:
_onTapUp
,
...
@@ -380,6 +383,7 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
...
@@ -380,6 +383,7 @@ class _CupertinoContextMenuState extends State<CupertinoContextMenu> with Ticker
child:
widget
.
child
,
child:
widget
.
child
,
),
),
),
),
),
);
);
}
}
...
...
packages/flutter/lib/src/cupertino/context_menu_action.dart
View file @
0a178f85
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
...
@@ -106,7 +107,9 @@ class _CupertinoContextMenuActionState extends State<CupertinoContextMenuAction>
...
@@ -106,7 +107,9 @@ class _CupertinoContextMenuActionState extends State<CupertinoContextMenuAction>
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
GestureDetector
(
return
MouseRegion
(
cursor:
widget
.
onPressed
!=
null
&&
kIsWeb
?
SystemMouseCursors
.
click
:
MouseCursor
.
defer
,
child:
GestureDetector
(
key:
_globalKey
,
key:
_globalKey
,
onTapDown:
onTapDown
,
onTapDown:
onTapDown
,
onTapUp:
onTapUp
,
onTapUp:
onTapUp
,
...
@@ -148,6 +151,7 @@ class _CupertinoContextMenuActionState extends State<CupertinoContextMenuAction>
...
@@ -148,6 +151,7 @@ class _CupertinoContextMenuActionState extends State<CupertinoContextMenuAction>
),
),
),
),
),
),
),
);
);
}
}
}
}
packages/flutter/test/cupertino/context_menu_action_test.dart
View file @
0a178f85
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'../rendering/mock_canvas.dart'
;
...
@@ -122,4 +125,29 @@ void main() {
...
@@ -122,4 +125,29 @@ void main() {
expect
(
_getTextStyle
(
tester
).
fontWeight
,
kDefaultActionWeight
);
expect
(
_getTextStyle
(
tester
).
fontWeight
,
kDefaultActionWeight
);
});
});
testWidgets
(
'Hovering over Cupertino context menu action updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
/// Cupertino context menu action without "onPressed" callback.
await
tester
.
pumpWidget
(
_getApp
());
final
Offset
contextMenuAction
=
tester
.
getCenter
(
find
.
text
(
'I am a CupertinoContextMenuAction'
));
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
contextMenuAction
);
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
// / Cupertino context menu action with "onPressed" callback.
await
tester
.
pumpWidget
(
_getApp
(
onPressed:
(){}));
await
gesture
.
moveTo
(
const
Offset
(
10
,
10
));
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
await
gesture
.
moveTo
(
contextMenuAction
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
kIsWeb
?
SystemMouseCursors
.
click
:
SystemMouseCursors
.
basic
,
);
});
}
}
packages/flutter/test/cupertino/context_menu_test.dart
View file @
0a178f85
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
void
main
(
)
{
...
@@ -193,6 +196,38 @@ void main() {
...
@@ -193,6 +196,38 @@ void main() {
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
_findStatic
(),
findsOneWidget
);
expect
(
_findStatic
(),
findsOneWidget
);
});
});
testWidgets
(
'Hovering over Cupertino context menu updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
final
Widget
child
=
_getChild
();
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
CupertinoPageScaffold
(
child:
Center
(
child:
CupertinoContextMenu
(
actions:
const
<
CupertinoContextMenuAction
>[
CupertinoContextMenuAction
(
child:
Text
(
'CupertinoContextMenuAction One'
),
),
],
child:
child
,
),
),
),
));
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
const
Offset
(
10
,
10
));
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
final
Offset
contextMenu
=
tester
.
getCenter
(
find
.
byWidget
(
child
));
await
gesture
.
moveTo
(
contextMenu
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
kIsWeb
?
SystemMouseCursors
.
click
:
SystemMouseCursors
.
basic
,
);
});
});
});
group
(
'CupertinoContextMenu when open'
,
()
{
group
(
'CupertinoContextMenu when open'
,
()
{
...
...
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