Browse Source

add native side implementation for osx.

Dan Walmsley 4 years ago
parent
commit
28fa72185c
1 changed files with 22 additions and 0 deletions
  1. 22 0
      native/Avalonia.Native/src/OSX/cursor.mm

+ 22 - 0
native/Avalonia.Native/src/OSX/cursor.mm

@@ -62,6 +62,28 @@ public:
             
             
         return S_OK;
         return S_OK;
     }
     }
+    
+    virtual HRESULT CreateCustomCursor (void* bitmapData, size_t length, AvnPixelSize hotPixel, IAvnCursor** retOut) override
+    {
+        if(bitmapData == nullptr || retOut == nullptr)
+        {
+            return E_POINTER;
+        }
+        
+        NSData *imageData = [NSData dataWithBytes:bitmapData length:length];
+        NSImage *image = [[NSImage alloc] initWithData:imageData];
+        
+        
+        NSPoint hotSpot;
+        hotSpot.x = hotPixel.Width;
+        hotSpot.y = hotPixel.Height;
+        
+        *retOut = new Cursor([[NSCursor new] initWithImage: image hotSpot: hotSpot]);
+        
+        (*retOut)->AddRef();
+        
+        return S_OK;
+    }
 };
 };
 
 
 extern IAvnCursorFactory* CreateCursorFactory()
 extern IAvnCursorFactory* CreateCursorFactory()