This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +58
-0
lines changed Expand file tree Collapse file tree 4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -443,6 +443,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/history.dart
443443FILE: ../../../flutter/lib/web_ui/lib/src/engine/houdini_canvas.dart
444444FILE: ../../../flutter/lib/web_ui/lib/src/engine/html_image_codec.dart
445445FILE: ../../../flutter/lib/web_ui/lib/src/engine/keyboard.dart
446+ FILE: ../../../flutter/lib/web_ui/lib/src/engine/mouse_cursor.dart
446447FILE: ../../../flutter/lib/web_ui/lib/src/engine/onscreen_logging.dart
447448FILE: ../../../flutter/lib/web_ui/lib/src/engine/path_to_svg.dart
448449FILE: ../../../flutter/lib/web_ui/lib/src/engine/picture.dart
Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ part 'engine/history.dart';
6161part 'engine/houdini_canvas.dart' ;
6262part 'engine/html_image_codec.dart' ;
6363part 'engine/keyboard.dart' ;
64+ part 'engine/mouse_cursor.dart' ;
6465part 'engine/onscreen_logging.dart' ;
6566part 'engine/path_to_svg.dart' ;
6667part 'engine/picture.dart' ;
@@ -216,6 +217,7 @@ void webOnlyInitializeEngine() {
216217 };
217218
218219 Keyboard .initialize ();
220+ MouseCursor .initialize ();
219221}
220222
221223class _NullTreeSanitizer implements html.NodeTreeSanitizer {
Original file line number Diff line number Diff line change 1+ // Copyright 2013 The Flutter Authors. All rights reserved.
2+ // Use of this source code is governed by a BSD-style license that can be
3+ // found in the LICENSE file.
4+
5+ // @dart = 2.6
6+ part of engine;
7+
8+ /// Provides mouse cursor bindings, such as the `flutter/mousecursor` channel.
9+ class MouseCursor {
10+ /// Initializes the [MouseCursor] singleton.
11+ ///
12+ /// Use the [instance] getter to get the singleton after calling this method.
13+ static void initialize () {
14+ _instance ?? = MouseCursor ._();
15+ }
16+
17+ /// The [MouseCursor] singleton.
18+ static MouseCursor get instance => _instance;
19+ static MouseCursor _instance;
20+
21+ MouseCursor ._() {}
22+
23+ // The kind values must be kept in sync with flutter's
24+ // rendering/mouse_cursor.dart
25+ static const Map <String , String > _kindToCssValueMap = < String , String > {
26+ 'none' : 'none' ,
27+ 'basic' : 'default' ,
28+ 'click' : 'pointer' ,
29+ 'text' : 'text' ,
30+ 'forbidden' : 'not-allowed' ,
31+ 'grab' : 'grab' ,
32+ 'grabbing' : 'grabbing' ,
33+ };
34+ static String _mapKindToCssValue (String kind) {
35+ return _kindToCssValueMap[kind] ?? 'default' ;
36+ }
37+
38+ void activateSystemCursor (String kind) {
39+ domRenderer.setElementStyle (
40+ domRenderer.glassPaneElement,
41+ 'cursor' ,
42+ _mapKindToCssValue (kind),
43+ );
44+ }
45+ }
Original file line number Diff line number Diff line change @@ -536,6 +536,16 @@ class EngineWindow extends ui.Window {
536536 textEditing.channel.handleTextInput (data, callback);
537537 return ;
538538
539+ case 'flutter/mousecursor' :
540+ const MethodCodec codec = StandardMethodCodec ();
541+ final MethodCall decoded = codec.decodeMethodCall (data);
542+ final Map <dynamic , dynamic > arguments = decoded.arguments;
543+ switch (decoded.method) {
544+ case 'activateSystemCursor' :
545+ MouseCursor .instance.activateSystemCursor (arguments['kind' ]);
546+ }
547+ return ;
548+
539549 case 'flutter/web_test_e2e' :
540550 const MethodCodec codec = JSONMethodCodec ();
541551 _replyToPlatformMessage (
You can’t perform that action at this time.
0 commit comments