Flutter macOS Embedder
FlutterMouseCursorPlugin.mm File Reference

Go to the source code of this file.

Functions

static NSCursor * GetCursorForKind (NSString *kind)
 

Variables

static NSString *const kMouseCursorChannel = @"@"flutter/mousecursor"
 
static NSString *const kActivateSystemCursorMethod = @"@"activateSystemCursor"
 
static NSString *const kKindKey = @"@"kind"
 
static NSString *const kKindValueNone = @"@"none"
 
static NSDictionary * systemCursors
 
NSMutableDictionary * cachedSystemCursors
 

Function Documentation

◆ GetCursorForKind()

static NSCursor* GetCursorForKind ( NSString *  kind)
static

Maps a Flutter's constant to a platform's cursor object.

Returns the arrow cursor for unknown constants, including kSystemShapeNone.

Definition at line 24 of file FlutterMouseCursorPlugin.mm.

24  {
25  // The following mapping must be kept in sync with Flutter framework's
26  // mouse_cursor.dart
27 
28  if ([kind isEqualToString:kKindValueNone]) {
29  NSImage* image = [[NSImage alloc] initWithSize:NSMakeSize(1, 1)];
30  return [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(0, 0)];
31  }
32 
33  if (systemCursors == nil) {
34  systemCursors = @{
35  @"alias" : [NSCursor dragLinkCursor],
36  @"basic" : [NSCursor arrowCursor],
37  @"click" : [NSCursor pointingHandCursor],
38  @"contextMenu" : [NSCursor contextualMenuCursor],
39  @"copy" : [NSCursor dragCopyCursor],
40  @"disappearing" : [NSCursor disappearingItemCursor],
41  @"forbidden" : [NSCursor operationNotAllowedCursor],
42  @"grab" : [NSCursor openHandCursor],
43  @"grabbing" : [NSCursor closedHandCursor],
44  @"noDrop" : [NSCursor operationNotAllowedCursor],
45  @"precise" : [NSCursor crosshairCursor],
46  @"text" : [NSCursor IBeamCursor],
47  @"resizeColumn" : [NSCursor resizeLeftRightCursor],
48  @"resizeDown" : [NSCursor resizeDownCursor],
49  @"resizeLeft" : [NSCursor resizeLeftCursor],
50  @"resizeLeftRight" : [NSCursor resizeLeftRightCursor],
51  @"resizeRight" : [NSCursor resizeRightCursor],
52  @"resizeRow" : [NSCursor resizeUpDownCursor],
53  @"resizeUp" : [NSCursor resizeUpCursor],
54  @"resizeUpDown" : [NSCursor resizeUpDownCursor],
55  @"verticalText" : [NSCursor IBeamCursorForVerticalLayout],
56  };
57  }
58  NSCursor* result = [systemCursors objectForKey:kind];
59  if (result == nil) {
60  return [NSCursor arrowCursor];
61  }
62  return result;
63 }

References kKindValueNone, and systemCursors.

Variable Documentation

◆ cachedSystemCursors

NSMutableDictionary* cachedSystemCursors

Definition at line 96 of file FlutterMouseCursorPlugin.mm.

◆ kActivateSystemCursorMethod

NSString* const kActivateSystemCursorMethod = @"@"activateSystemCursor"
static

Definition at line 12 of file FlutterMouseCursorPlugin.mm.

◆ kKindKey

NSString* const kKindKey = @"@"kind"
static

Definition at line 13 of file FlutterMouseCursorPlugin.mm.

◆ kKindValueNone

NSString* const kKindValueNone = @"@"none"
static

Definition at line 15 of file FlutterMouseCursorPlugin.mm.

Referenced by GetCursorForKind().

◆ kMouseCursorChannel

NSString* const kMouseCursorChannel = @"@"flutter/mousecursor"
static

Definition at line 10 of file FlutterMouseCursorPlugin.mm.

◆ systemCursors

NSDictionary* systemCursors
static

Definition at line 17 of file FlutterMouseCursorPlugin.mm.

Referenced by GetCursorForKind().

systemCursors
static NSDictionary * systemCursors
Definition: FlutterMouseCursorPlugin.mm:17
kKindValueNone
static NSString *const kKindValueNone
Definition: FlutterMouseCursorPlugin.mm:15