Skip to content

[Desktop] Support custom cursor  #89351

@linxuebin1990

Description

@linxuebin1990

According to #58260, in pre flutter version, we can custom cursor shape by self image.
But, now it is not work.
Now we can achieve this by only modifying a few core methods.

var listnode = document.getElementsByTagName('flt-glass-pane') 
// cast node to Element, then
node.style.setProperty('cursor', 'url(\'https://www.ernegonzal.com/wp-content/uploads/2020/02/hand-2.png\'), auto');

This is according mouse_cursor.dart

 static const Map<String, String> _kindToCssValueMap = <String, String>{
    'alias': 'alias',
    'allScroll': 'all-scroll',
     // ...
  };
  static String _mapKindToCssValue(String? kind) {
    return _kindToCssValueMap[kind] ?? 'default';
  }

  void activateSystemCursor(String? kind) {
    DomRenderer.setElementStyle(
      domRenderer.glassPaneElement!,
      'cursor',
      _mapKindToCssValue(kind),
    );
  }

which is called by fellow example code

MouseRegion(
  cursor: SystemMouseCursors.click,
  child: Container(),
),

So, can provide SystemMouseCursors.custom and trans image url to support custom cursor shape ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: desktopRunning on desktopa: mouseIssues related to using a mouse or mouse supportc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions